0% found this document useful (0 votes)
13 views5 pages

Data Engineer - SQL Assessment Inference Labs - New

Uploaded by

vigneshem10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Data Engineer - SQL Assessment Inference Labs - New

Uploaded by

vigneshem10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SQL Assessment

Instructions:

 Kindly use any method/technique that you find suitable to get to the required results
 Write your name and contact no in Solution Sheet so that we can keep a track of your
work.

All the best!

Question 1:

The students table contains attendance record for students in a particular week (Monday to Saturday with
no holidays in between).

Table structure:

Column Name Values


Date Date Type
Name Char Type
Present Char Type; Either “Yes” or “No” values only

Write a query to identify students (User_ID) who have attended classes for at least 3 consecutive
days(Attendance of 3 or more consecutive days)? Note: Consider only given below Example table to
write your query and not Logic Table.
Logic
For User
1
Date Present
2021-09-06 Yes
2021-09-07 No Attended 4 Consecutive days
2021-09-08 Yes
2021-09-09 Yes
2021-09-10 Yes
2021-09-11 Yes

For User
2
Date Present
2021-09-06 Yes Attended 4 Consecutive days

2021-09-07 Yes
2021-09-08 Yes
2021-09-09 Yes
2021-09-10 No
Example Table: (You may use this table 2021-09-11 No
to test your query)
For User
Date User_ID Present 3
2021-09-06 User_01 Yes
Date Present
2021-09-06 User_02 Yes Attended 3 Consecutive days
2021-09-06 Yes
2021-09-06 User_03 Yes
2021-09-07 Yes
2021-09-06 User_04 Yes
2021-09-08 No
2021-09-06 User_05 Yes
2021-09-09 Yes
2021-09-07 User_01 No
2021-09-10 Yes
2021-09-07 User_02 Yes
2021-09-11 Yes
2021-09-07 User_03 Yes
2021-09-07 User_04 No
2021-09-07 User_05 Yes
For User
2021-09-08 User_01 Yes 4
2021-09-08 User_02 Yes Date Present Attended 2 Consecutive days
2021-09-08 User_03 No 2021-09-06 Yes
2021-09-08 User_04 Yes 2021-09-07 No
2021-09-08 User_05 Yes 2021-09-08 Yes
2021-09-09 User_01 Yes 2021-09-09 No
2021-09-09 User_02 Yes 2021-09-10 Yes
2021-09-09 User_03 Yes 2021-09-11 Yes
2021-09-09 User_04 No
2021-09-09 User_05 Yes For User
2021-09-10 User_01 Yes 5
2021-09-10 User_02 No Attended 6 Consecutive days
2021-09-10 User_03 Yes Date Present
2021-09-10 User_04 Yes 2021-09-06 Yes
2021-09-10 User_05 Yes 2021-09-07 Yes
2021-09-11 User_01 Yes 2021-09-08 Yes
2021-09-11 User_02 No 2021-09-09 Yes
2021-09-11 User_03 Yes 2021-09-10 Yes
2021-09-11 User_04 Yes 2021-09-11 Yes
Question 2:
The matches table contains data for cricket matches between different teams and the winner.

Match_ID Team_1 Team_2 Winner


0001 CSK MI MI
0001 MI CSK MI
0002 MI KKR MI
0003 RCB RR RR
0003 RCB RR RR
0002 KKR MI MI
Write a query to filter out redundant records from the table (e.g. row 1 and row 2 refers to the same
match, so we need to keep only 1 of these rows in resultant table. Use only select queries not Delete
queries to come up with solution.)

Question 3:
Using the transactions table as described below, find out the count of users who transacted for
the first time on a Monday (Not to be mistaken for identifying customers who have transacted
on any Monday).

Example Table: (You may use this


table to test your query)
Transaction_ID User_ID Transaction_Date Amount
Transaction_01 User_01 2021-09-06 532
Transaction_02 User_02 2021-09-05 631
Transaction_03 User_03 2021-09-06 7214
Transaction_04 User_04 2021-09-08 131
Transaction_05 User_01 2021-09-08 13
Log
Transaction_06 User_03 2021-09-09 72
ic:Transaction_07 User_05 2021-09-11 139
Transaction_08 User_05 2021-09-13 214

Expected output: User_01 and


User_03 only, so the count is 2.
Question 4:
From the following salaries table, write queries to get the following:

a. Minimum salary, and the employee details related to it.


b. Running total of salary for all employees, ordered by emp_id.

emp_id emp_name salary


1 Parth 15000
2 Sheryl 22500
3 Priya 33000
4 Arun 48000
5 Vivek 23500
6 Anand 28000
7 Shruti 40000

Question 5:
An e-commerce app allows users to share the product on various social platforms with their
friends before purchasing. A user has to view the product, can share it with friends and can
decide to purchase it or not. The following tables capture the user actions for a few products

a. Product_View

Product_Id Product_Views
1001 1200
1002 1305
1003 1000
1005 700

b. Product_Purchase

Order_ID Product_Id Order_Quantity


OD001 1001 2
OD002 1001 1
OD003 1003 4
OD004 1002 2
OD005 1001 1
OD005 1003 3
c. Product_Shares

Product_Id Product_Shares
1001 200
1003 130
1002 80

Write a query to fetch data in the following manner:

Product_ID Product_Views Order_Quantity Product_Shares


1001 1200 4 200
1002 1305 2 80
1003 1000 7 130
1005 700

You might also like