Premium members by city

EasyJoins and aggregationFood delivery

The problem

ClearBite Premium gives members free delivery. How many Premium customers does each city have?

Return city (the city's name, not its id) and premium_customers.

Tables · ClearBite food delivery

ClearBite is a fictional food-delivery app in 8 Indian cities. The data covers calendar year 2025 and is invented.

Click a table or column name to insert it into your query. Open a table to see its columns.

9,975 rows · 11 columns
  • INTEGER · primary key
  • INTEGER · → customers
  • INTEGER · → restaurants
  • TIMESTAMP · local time
  • TEXT · delivered | cancelled | refunded
  • TEXT · upi | card | cod | wallet
  • TEXT · → coupons, NULL if none
  • INTEGER · rupees, food only
  • INTEGER · rupees
  • INTEGER · rupees
  • INTEGER · subtotal − discount + delivery_fee
Sample rows (9,975 total)
Sample rows from orders
order_idcustomer_idrestaurant_idordered_atstatuspayment_methodcoupon_codesubtotaldiscountdelivery_feetotal
121261152025-01-01 12:05:36deliveredwalletNULL180039219
27972162025-01-01 12:52:20cancelledupiNULL150041191
3172422025-01-01 12:53:25deliveredupiNULL4502974
42135592025-01-01 12:57:02cancelledupiNULL195034229
522011912025-01-01 13:38:18deliveredcodNULL950095
16,314 rows · 4 columns
  • INTEGER · → orders
  • INTEGER · → menu_items
  • INTEGER
  • INTEGER · rupees
Sample rows (16,314 total)
Sample rows from order_items
order_iditem_idquantityunit_price
19571180
217901150
318145
44871195
51575195
3,000 rows · 6 columns
  • INTEGER · primary key
  • TEXT · not unique
  • INTEGER · → cities
  • DATE
  • TEXT · organic | referral | paid_social | search_ads | offline, can be NULL
  • BOOLEAN · free delivery membership
Sample rows (3,000 total)
Sample rows from customers
customer_idnamecity_idsignup_dateacquisition_channelis_premium
1Bhavna Khan62024-04-28search_adsfalse
2Ayesha Joshi32025-05-29search_adsfalse
3Isha Nair22025-12-03offlinefalse
4Pranav Ghosh52025-11-06NULLfalse
5Farhan Gowda62025-06-28paid_socialfalse
300 rows · 7 columns
  • INTEGER · primary key
  • TEXT · not unique
  • INTEGER · → cities
  • TEXT
  • BOOLEAN
  • INTEGER · rupees
  • DATE
Sample rows (300 total)
Sample rows from restaurants
restaurant_idnamecity_idcuisineis_veg_onlycost_for_twoonboarded_date
1Slice Kitchen5Pizzafalse8502023-10-18
2Napoli Pizza Co.1Pizzafalse7502023-09-18
3Hakka Garden8Chinesefalse6002022-02-08
4Sprout Kitchen2Healthyfalse8502025-09-28
5Coastal Tiffins6South Indiantrue4002025-07-27
2,482 rows · 6 columns
  • INTEGER · primary key
  • INTEGER · → restaurants
  • TEXT
  • TEXT · main | starter | bread | rice | dessert | beverage
  • BOOLEAN
  • INTEGER · rupees
Sample rows (2,482 total)
Sample rows from menu_items
item_idrestaurant_iditem_namecategoryis_vegprice
11Pasta Arrabbiatamaintrue250
21Choco Lava Cakedesserttrue120
31BBQ Chicken Pizzamainfalse365
41Cold Coffeebeveragetrue135
51Farmhouse Pizzamaintrue350
9,173 rows · 6 columns
  • INTEGER · primary key, → orders (delivered and refunded orders only)
  • INTEGER · → delivery_partners
  • TIMESTAMP
  • TIMESTAMP
  • NUMERIC(4,1)
  • INTEGER · time promised at checkout, from ordered_at
Sample rows (9,173 total)
Sample rows from deliveries
order_idpartner_idpicked_up_atdelivered_atdistance_kmpromised_minutes
11822025-01-01 12:31:482025-01-01 12:46:294.835
32002025-01-01 13:09:132025-01-01 13:12:552.230
52182025-01-01 13:51:372025-01-01 14:15:142.830
71082025-01-01 16:44:532025-01-01 16:49:292.325
81002025-01-01 18:32:462025-01-01 18:36:451.120
4,181 rows · 4 columns
  • INTEGER · primary key, → orders
  • INTEGER · 1–5
  • INTEGER · 1–5, can be NULL
  • TIMESTAMP
Sample rows (4,181 total)
Sample rows from ratings
order_idfood_ratingdelivery_ratingrated_at
34NULL2025-01-02 08:00:55
55NULL2025-01-01 21:55:14
7452025-01-02 06:12:29
9442025-01-03 02:11:41
10342025-01-02 15:35:00
400 rows · 5 columns
  • INTEGER · primary key
  • TEXT
  • INTEGER · → cities
  • TEXT · bike | scooter | ev_scooter | bicycle
  • DATE
Sample rows (400 total)
Sample rows from delivery_partners
partner_idnamecity_idvehicle_typejoined_date
1Ananya Gowda5scooter2023-01-08
2Omkar Ghosh3bike2024-08-21
3Ayesha Qureshi8bike2025-03-02
4Vikram Krishnan7bike2023-02-12
5Varun Reddy5bike2023-08-15
8 rows · 7 columns
  • TEXT · primary key
  • TEXT
  • INTEGER
  • INTEGER · rupees
  • INTEGER · rupees, on subtotal
  • DATE
  • DATE
Sample rows (8 total)
Sample rows from coupons
coupon_codedescriptiondiscount_pctmax_discountmin_order_valuevalid_fromvalid_to
WELCOME5050% off your first order501001992025-01-012025-12-31
BITE2020% off any order20802992025-01-012025-12-31
WEEKEND1515% off on Saturdays and Sundays15752492025-01-012025-12-31
IPL2525% off during the cricket season251253992025-03-222025-06-03
MONSOON1010% off in July and August10601992025-07-012025-08-31
8 rows · 4 columns
  • INTEGER · primary key
  • TEXT
  • TEXT
  • INTEGER · 1 = metro, 2 = smaller city
Sample rows (8 total)
Sample rows from cities
city_idcitystatetier
1BengaluruKarnataka1
2MumbaiMaharashtra1
3DelhiDelhi1
4HyderabadTelangana1
5PuneMaharashtra1

Next: Big orders in the Diwali rush →

Ctrl/⌘ + Enter runs the query. Table and column names are suggested as you type. Press Esc then Tab to leave the editor with the keyboard.

Expected output (8 rows)
Expected output
citypremium_customers
Indore11
Mumbai93
Pune39
Jaipur11
Delhi74
Bengaluru95
Chennai39
Hyderabad59

Row order doesn’t matter for this question. Numbers are compared with a tiny tolerance; text must match exactly.

Stuck?

Stored on this device only. Your latest query and “solved” status are remembered in this browser only. They don’t sync between devices, and clearing your browser data removes them.