DSI Guide - What To Expect in SQL Tests

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

SQL TESTS

IN DATA SCIENCE INTERVIEWS

WHAT TO EXPECT...
You will often be provided with several
key data tables (or sometimes just the
table structures...)
customers
customer_id country age

AAA UK 47

products BBB Germany 19

product_id product_name CCC USA 29

181 Milk ... ... ...

427 Bread
transactions
211 Beer
customer_id transaction_id product_id sales
... ...
AAA 001 427 34.22

AAA 001 665 9.99

CCC 003 211 101.87

... ...

Tasks start easy...

...then get harder


Basic tasks...
Task SQL Clauses to know...

Selection & Filtering SELECT + WHERE

Finding Unique Values DISTINCT + COUNT DISTINCT

Merging Multiple Tables JOINS (LEFT, INNER, FULL)

Aggregating & Summarising SUM, MAX, COUNT ( + GROUP BY )

Ordering ORDER BY

Appending UNION, UNION ALL


More complex tasks...

Task SQL Clauses to know...

Working with dates DATEDIFF, DATEADD, DATETRUNC

Conditional Logic CASE WHEN

Apply logic to a RANK, NTILE, LAG, LEAD


set of rows ( Window Functions)

Combinations CROSS JOIN


Don’t forget about TEMP
TABLES or CTE! These
might make solving the
task possible (or just
make your life easier!)
Read each question
carefully - think
about exactly what it
is asking, because...
Near the end, they may
try to lure you into an
obvious solution...where in
reality, more thought is
required!
For example...
Q) "Find the highest value for
column X after joining Table A &
Table B"

This may seem easy, but your


query could return multiple
rows if there was a tie in the
data – is this ok?!
If you don't know the exact
syntax - don't leave the
question blank...

Write down what you think


should happen in words!
Example Test - Data
For this test, we have 5 tables that can be accessed in the grocery_db schema

of the DATA SCIENCE INFINITY database. Example data from each table can

be seen below...
customer_details

product_areas

transactions

loyalty_scores

campaign_data
Example Test - Questions
1) How many rows are there in the transactions table?

2) Return the customer_id for the customer who lives farthest from the store

3) Return the number of unique customers in the customer_details table, split by

gender

4) Return the total sales for each product_area_name for July 2020 - in the

order of highest sales to lowest sales

5) For the customers with a customer_loyalty_score, divide them up into 10

deciles, and calculate the average distance_from_store for each decile

6) Return a list of all customer_id's that DO NOT have a loyalty_score (i.e. they

are in the customer_details table, but not in the loyalty_scores table)

7) Return data showing, for each product_area_name - the total sales, and the

percentage of overall sales that each product_area makes up


Want to learn SQL (and get

the data & solutions to

those test questions, and

much more)

?
Want to also learn Python,

Statistics, Machine

Learning, Deep Learning, &

the vital soft-skills

?
Want to land an incredible

role in the exciting, future-

proof, and lucrative field of

Data Science?

?
"I had over 40 interviews without an offer.
After DSI I quickly got 7 offers including one
at KPMG and my amazing new role at
Deloitte!" - Ritesh

"The best program I've been a part of, hands


down"
- Christian

"DSI is incredible - everything is taught in


such a clear and simple way, even the more
complex concepts!"
- Arianna
>> https://data-science-infinity.teachable.com

You might also like