SQL Question Bank PDF
SQL Question Bank PDF
SQL Question Bank PDF
of Contents
Introduction 1.1
SQL Interview 1.2
1. Interview #1 1.2.1
2. Interview #2 1.2.2
SQL Real World 1.3
1. School Attendance Pivot 1.3.1
2. School Absent 10 contiguous days 1.3.2
3. Inventory increamental load dimension and fact 1.3.3
Common Use 1.4
1. 1.4.1
1
Introduction
SQL Notes
2
1. Interview #1
We have a set of customer order data and have been asked to provide an analysis of that
data. Before we produce this analysis we need to clean the data based on certain
qualifications specified below.
To create the analysis you may run multiple standard SQL statements, generate temporary
tables, and add tables.
Data Cleanup
ORDER data may have quality issues that are identifiable by the AMOUNT of the order. For
each DEPARTMENT a MIN and MAX amount is defined in DEPARTMENT_RANGE.
ORDER data that is outside of the specified range for the department should be ignored. For
example, an order of a book that costs $2500 would be ignored.
Create a profile of customers based on order history with each customer listed in only one
category. The category ordering is defined below. This analysis will be run weekly.
3
1. Interview #1
Further Data Cleanup After deploying the profile we realize that there are rows that
represent the same order but from different sources. ORDER data comes from multiple
sources. An ORDER from one data source may also exist in another data source. To de-
duplicate this data we will use the combination of timestamp, customer, and product as a
unique value. Some data sources have a higher quality than others. When identifying which
row to use between two rows with the same timestamp/customer/product we should
prioritize those from a higher quality source. Quality is currently defined in the order:
1. WEBSITE
4
1. Interview #1
2. PHONE
3. POST
Download Solution
5
2. Interview #2
6
1. School Attendance Pivot
Objective:
Create a report, one school per row.
Input
Output
...
...
...
Note:
One Student might have multiple school(student 12082 has 2 schools), we will use the most
recent school the student attended
7
1. School Attendance Pivot
Download Solution
8
2. School Absent 10 contiguous days
Objective:
find students missed school 10 days straight
Input
Question: Get all Students who absent 10 contiguous days with 'No Reason'
9
2. School Absent 10 contiguous days
Output
Download Solution
10
3. Inventory increamental load dimension and fact
Firm
Product
Style
Segment
Discipline
Given
ModelID 'DTCHONEY', (First 3 letter of ModelID: FirmID; Rest: StyleID)
FirmName 'DTC International',
SegmentID 'INTL'
11
3. Inventory increamental load dimension and fact
Download Solution
12
3. Inventory increamental load dimension and fact
13