Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Users by Order Frequency

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Top Users by Order Frequency. Start with the requirements and the two tables on the right.

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.

Problem

Delivery Hero India wants to identify its most frequent users on the food delivery platform. Write a PostgreSQL query to rank users by the number of completed orders placed during the previous calendar month, using 2025-03-15 as the reporting date.

Requirements

  1. Consider only orders from the previous calendar month, 2025-02-01 through 2025-02-28.
  2. Count only orders whose status is delivered.
  3. Return the top 10 users with their ID, name, and order frequency, ordered by frequency descending and user ID ascending as a tie-breaker.

Schema

users
ColumnTypeDescription
user_idPKINTEGERUnique user identifier
user_nameVARCHAR(100)User display name
orders
ColumnTypeDescription
order_idPKINTEGERUnique order identifier
user_idINTEGERReferences users.user_id
order_timestampTIMESTAMPTimestamp when the order was placed
statusVARCHAR(20)Order fulfillment status
Tablesusersorders
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results