latest-uber-sql-interview

3 Latest Uber SQL Interview Questions

John H.

John H.

I love iced coffee, cute pictures of dogs, and SQL. I've previously worked at Big Tech as a data analyst and now spend my time writing and helping job seekers ace their big tech interview @ bigtechinterviews.com.

3 Latest Uber SQL Test Interview Questions

In the fast-paced realm of data analytics, staying abreast of the latest interview trends and questions is crucial for aspiring professionals seeking opportunities with industry leaders like Uber. As technology continues to evolve, so does the demand for skilled individuals who can navigate complex datasets using SQL. In this competitive landscape, mastering the Uber SQL test is a key milestone for anyone eyeing roles such as data analyst, data scientist, or business analyst within the Uber ecosystem. In this article, we delve into the intricacies of the 3 latest Uber SQL test interview questions, shedding light on what candidates can expect and offering valuable insights to help them excel in their Uber interviews.

Want to practice more SQL interview questions like this with on-demand support and a dynamic SQL playground? Learn more here!

We’ve analyzed over 50,000 interviews from pre-IPO to Fortune 500 companies at Big Tech Interviews (BTI) to curate an exclusive list of the latest SQL interview questions and solutions so you can ace your next interview!

You’re about to read the 3 latest Uber data science, business analyst, and data analyst SQL interview questions and solutions.  

 

Uber SQL Interview Question 72: Time elapsed between trips

 

Prompt: Write a query to find for each user that has taken at least two trips with Uber, what is the time that elapsed between first trip and second trip?

Table: sign_ups
+--------+----------------+
|rider_id|signup_timestamp|
+--------+----------------+
|1       |2022-03-01      |
|2       |2022-03-01      |
|3       |2022-03-01      |
|4       |2022-03-01      |
|5       |2022-03-01      |
+--------+----------------+
Table: trips +-------+--------+---------+--------------+ |trip_id|rider_id|driver_id|trip_timestamp| +-------+--------+---------+--------------+ |1 |1 |2 |2022-02-01 | |1 |2 |2 |2022-03-11 | |1 |1 |2 |2022-04-01 | |1 |1 |2 |2022-05-21 | |1 |2 |2 |2022-06-01 | |1 |3 |2 |2022-07-31 | +-------+--------+---------+--------------+

Output

+---------+------------------------+---------------------+
|rider_id |trip_timestamp          |time_between_two_trip|
+---------+------------------------+---------------------+
|1        |2022-05-21T00:00:00.000Z|null                 |    
|1        |2022-04-01T00:00:00.000Z|{"days":50}          |
|1        |2022-02-01T00:00:00.000Z|{"days":59}          |
|2        |2022-06-01T00:00:00.000Z|null                 |
|2        |2022-03-11T00:00:00.000Z|{"days":82}          |
+---------+------------------------+---------------------+

Solution

SELECT rider_id,
trip_timestamp,
lag(trip_timestamp, 1) OVER (PARTITION BY rider_id
ORDER BY trip_timestamp DESC) - trip_timestamp
AS time_between_two_trip
FROM trips
WHERE rider_id in
(SELECT rider_id
FROM trips
GROUP BY rider_id
HAVING COUNT (*) >1)

Uber SQL Interview Question 57: Find the third order

 

Prompt: Write a query to find how many users placed their third order containing a product owned by the ATG (holding company) on or after 9/21/22? Only consider orders containing at least one ATG holding company product.

Table: brands
+--------+----------+------------------+--------------------+
|brand_id|brand_name|holding_company_id|holding_company_name|
+--------+----------+------------------+--------------------+
|1       |A5        |10                |Beam Suntory        |
|2       |A4        |9                 |CDE                 |
|3       |A3        |8                 |ATG                 |
|4       |A2        |7                 |Chivas              |
|5       |A1        |6                 |MMT                 |
+--------+----------+------------------+--------------------+
Table: orders +--------+-------+----------+--------+-----+--------+----------+--------+ |order_id|user_id|product_id|brand_id|price|quantity|date |store_id| +--------+-------+----------+--------+-----+--------+----------+--------+ |1 |111 |3 |1 |100 |2 |2022-09-21|12 | |2 |222 |7 |2 |123 |30 |2022-12-09|34 | |3 |222 |9 |1 |14 |1 |2020-05-02|435 | |4 |222 |11 |3 |140 |40 |2019-11-03|23 | |5 |333 |13 |5 |120 |15 |2019-10-01|45 | +--------+-------+----------+--------+-----+--------+----------+--------+

Output

+-------------+
|user_id      |
+-------------+
|222          |
+-------------+

Solution

WITH count_orders AS
  (SELECT user_id,
          count(order_id) AS total_orders
   FROM orders
   WHERE date::DATE >= '2019-09-21'::DATE
   GROUP BY user_id)
SELECT user_id
FROM count_orders
WHERE EXISTS
    (SELECT order_id
     FROM orders o
     LEFT JOIN brands b ON o.brand_id = b.brand_id
     WHERE holding_company_name = 'ATG')
     AND total_orders >= 3;

Uber SQL Interview Question 71: Find the latest timestamp for users who took at least one trip

 

Prompt: Write a query to find the latest trip timestamp for each user who took at least one trip.

Note: Order by rider id ASC”

Table: sign_ups
+--------+----------------+
|rider_id|signup_timestamp|
+--------+----------------+
|1       |2022-03-01      |
|2       |2022-03-01      |
|3       |2022-03-01      |
|4       |2022-03-01      |
|5       |2022-03-01      |
+--------+----------------+
Table: trips +-------+--------+---------+--------------+ |trip_id|rider_id|driver_id|trip_timestamp| +-------+--------+---------+--------------+ |1 |1 |2 |2022-02-01 | |1 |2 |2 |2022-03-11 | |1 |1 |2 |2022-04-01 | |1 |1 |2 |2022-05-21 | |1 |2 |2 |2022-06-01 | |1 |3 |2 |2022-07-31 | +-------+--------+---------+--------------+

Output

+---------+------------------------+
|rider_id |latest_trip_timestamp   |
+---------+------------------------+
|1        |2022-05-21T00:00:00.000Z|
|2        |2022-06-01T00:00:00.000Z|
|3        |2022-07-31T00:00:00.000Z|
+---------+------------------------+

Solution

SELECT rider_id,
max(trip_timestamp) AS latest_trip_timestamp
FROM trips
GROUP BY rider_id
ORDER BY rider_id;

Want to practice more Uber SQL interview questions like this with on-demand support and a dynamic SQL playground? Learn more here!

 

We’ve analyzed over 50,000 interviews from the latest data science, data analyst, data engineer, business analyst, and business intelligence engineer roles being filled by pre-IPO to Fortune 500 companies at Big Tech Interviews (BTI) to curate an exclusive list of the latest SQL interview questions and solutions so you can ace your next interview! 

Read More: Data Analyst SQL Query Interview Questions

Do you want to ace your SQL interview?

Practice free and paid real SQL interview questions with step-by-step answers.

Do you want to Ace your SQL interview?

Practice free and paid SQL interview questions with step-by-step video solutions!