SQL for Data Science


SQL (Structured Query Language) is the most used language in analytics whether you are Data Scientist, Data Analyst or Data Engineer. The easiest, as well as one of the most necessary skill a data science aspirant should acquire is SQL.

SQL is the most widely used programming language while working with databases. The various relational database systems that supports SQL are MySQL, SQL Server, SQLite, Postgres, Oracle and Snowflake.  SQL becomes one of the most important concepts to master in this field of Data Science.

So, we will be covering the SQL in three parts: Beginners, Intermediate and Advanced.

Table of Contents

  • SQL Setup
  • Beginners SQL
  • Intermediate SQL
  • Advanced SQL
  • SQL Assignment

SQL Setup

We will be using MODE.COM for the SQL tutorials and hands on.

First let’s setup the SQL environment to do practical hands on lessons. For setup, follow the below steps:

1. https://app.mode.com/signup

Sign up on mode.com using email id

2. Verify the email address on your mail id.

3. After verification, a link will be open and you will see the webpage shown below. Click on ‘+‘ button on the top right side to open the code editor.

Personal Account Homepage – Mode.com

4. This is the code editor that we will using to do hands on SQL exercises. Happy Coding!

Code Editor – Mode.com

So, the setup is completed and now let’s move on to learn the SQL in a practical way.

Beginners SQL

Click Here

Beginners SQL

Intermediate SQL

Click Here

Intermediate SQL

Advanced SQL

Click Here

Advanced SQL

SQL Assignment

Let’s take some time and check SQL aptitude for data science by attempting the following tests. These tests contains questions based on real life data science project situations in which one have to fetch the data in the required form. Give it a try and submit the following assignments to test your skills.

SQL Test 1:

There are 2 SQL Tables named ‘orders’ and ‘order_items’.

  • order table has data in columns: order_id, user_phone, store_id, merchant_id, payment_status, payment_method, pay_amount, hash, created_at, updated_at
  • order_items has following columns: order_id, item_id, name, status, quantity, price, created_at, updated_at

Solve the 7 questions given below using SQL query.

SQL Test 2:

Table named ‘Orders’ contains data in columns: order_id, order_date, customer_id, sku and sales. Solve the 2 questions given below using SQL query.

Excel for Data Science

Python for Data Science

Leave a Comment

Keytodatascience Logo



Join our email list to receive the latest updates.

© 2022 KeyToDataScience