Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Average Order Value by Region

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

Your question is Average Order Value by Region. 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

Whatnot's operations team wants a quick view of buyer monetization by geography. Write a SQL query to calculate the average order value per user by region.

Requirements

  1. Join orders to users using user_id.
  2. Group results by region.
  3. Return each region and its average order value as avg_order_value.
  4. Exclude orders that are not linked to a valid user region.
  5. Order the final result by avg_order_value descending, then region ascending.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
usernameVARCHAR(50)Whatnot username
regionVARCHAR(50)User region
signup_dateDATEDate the user joined Whatnot
orders
ColumnTypeDescription
order_idPKINTUnique order identifier
user_idINTUser who placed the order
order_totalDECIMAL(10,2)Total order amount
order_dateDATEDate of purchase
Tablesusersorders
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results