Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Identifying Power Users with SQL
00:00
5 left

Identifying Power Users with SQL

MediumSQL · PostgreSQL

Problem

How would you identify power users in our database using complex joins and aggregations at Delivery Hero?

Treat a power user as a customer with at least three completed orders, at least 100 in total completed order value, and orders from at least two restaurants during Q1 2025.

Output

  1. Return one row per qualifying customer with user_id, user_name, city, completed_orders, total_spend, and restaurants_used.
  2. Exclude customers who do not meet all three criteria.
  3. Order by total_spend descending, then completed_orders descending, then user_name ascending.

Schema

users
ColumnTypeDescription
user_idPKINTUnique Delivery Hero customer identifier
user_nameVARCHAR(100)Customer display name
cityVARCHAR(80)Customer city
orders
ColumnTypeDescription
order_idPKINTUnique order identifier
user_idINTCustomer who placed the order
restaurant_idINTRestaurant associated with the order
statusVARCHAR(20)Order lifecycle status
order_dateDATEDate the order was placed
total_amountNUMERIC(10,2)Total order value
restaurants
ColumnTypeDescription
restaurant_idPKINTUnique restaurant identifier
restaurant_nameVARCHAR(120)Restaurant name
cityVARCHAR(80)Restaurant city
Tablesusersordersrestaurants
Interviewer

Your question is Identifying Power Users with SQL. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.