0% found this document useful (0 votes)
4 views4 pages

SQL Assessment Test

The document contains an SQL assessment test with five questions focusing on querying user data, supply hours, and driver earnings. Each question provides a specific scenario and SQL query examples to retrieve relevant information from the database. The test is designed to evaluate the understanding of SQL syntax and data manipulation techniques.

Uploaded by

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

SQL Assessment Test

The document contains an SQL assessment test with five questions focusing on querying user data, supply hours, and driver earnings. Each question provides a specific scenario and SQL query examples to retrieve relevant information from the database. The test is designed to evaluate the understanding of SQL syntax and data manipulation techniques.

Uploaded by

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

SQL Assessment Test

Time: 60 minutes

Q1: We need to find users who were tagged with the tag ‘magic’ on 2021-11-10.

Select ‘Driver Id’ from table


Where tag = ‘magic’
And ‘Applied Date’ = ‘2021-11-10’

Q2: Query to show supply hours and trips for drivers based on Country.
Select country,sum(‘minutes Online’/60.0),’ sum(trips ID)
From drivers as di
Inner join supply as sup
On di.id = sup.Driver ID
Inner join trips
On di.id = trips.driver id
Group by di.country
country,
SUM(supply_hours) AS total_supply_hours,
SUM(trips) AS total_trips
FROM
driver_data
GROUP BY
country

Q3: Disney World is having a fun holiday getaway for all those people who stayed for the entire
duration of their Star Wars extravaganza.
a) Query for those individuals eligible for the holiday getaway.
Hint: duration of Star Wars extravaganza was 3 days

Table: Disney

The output should look like this

Select ‘first name’, ‘last name’, address


From Disney
Where datediff((Check out)-(check In)) >= 3

Q4: Given the data below, query for supply hours of all those drivers who paid during the months of
July to August. The drivers’ paid status should be indicated clearly in a separate column.
Note a driver is considered to have paid if they have the tag ‘zippo’, ‘bolt’ tag means partial
payment, and ‘light’ means non-payment.

You query should yield the below result

One way is defining a new table in the database as status

Select ‘driver id’,sum(hours) as supply hrs,


case
when tags = 'zippo' then 'Paid'
when tags = 'bolt' then 'Partial Payment'
else 'Non-Payment'
end as Output
from table1
Inner join table2
using(Driver ID)
WHERE
month(Date str) between 7 and 8
and tags IN ('Zippo', 'Bolt', Light')
Group by table1.drivers id, table2.tags
Q5: Write down a query to show for week on week driver level earnings in Pakistan.
Hint: You’ll need to use all 3 tables, the earning cycle for the entire week is considered complete on
Sundays (Day 7 of the week).

Select drivers.id, sum(earnings.earnings) as weekly_earnings


From drivers
Inner join earnings
Using (id)
Inner join date
On date.id = earnings.date
Where drivers.country= ‘Pakistan’
Group by drivers.id

You might also like