Uber Analytics Test Q1 & Q3
Uber Analytics Test Q1 & Q3
a. Continent
b. Country
c. Population
The table has a row for each country in the world
• Write queries to output the name of all continents where every country in that
continent has population below 300 Mn {eg Antarctica, Europe etc.} [4]
• Ans: Create Table Table2 as select *, Case when Population < 300 Mn then 0 else
1 end as Pop_indicator from Table1;
• Ans: Select Distinct Continent from Table1 where Continent not in (select distinct
Continent from Table1 where population > 300 Mn) ;
3. A table T1 has 3 columns: TripID, CustomerID, Date Time of trip
TripID is unique for every trip while customerID is unique to a customer. A customer can have
multiple trips.
• What is the average trips/customer monthly number (SQL Query to calculate) [2]
• Ans: Create Table Table2 as select *, (case when DATEPART(month, Datetime) <
10 then concat(DATEPART(year, Datetime),0,DATEPART(month, Datetime)) else
concat(DATEPART(year, Datetime),DATEPART(month,Datetime)) end) AS Month
from Table1;
• Create a table with same columns as T1 + an additional column that counts Trips
by same customer in last 24 hrs ( for each TripID, count the number of trips by same
customerID in 24 hour from datetime of that tripID) [4]