Interview Query

Average Order Value

Upvote
32
Downvote
Save
Mark Completed
Have you seen this question before?

Given three tables, representing customer transactions and customer attributes:

Write a query to get the average order value by gender.

Note: We’re looking at the average order value by users that have ever placed an order. Additionally, please round your answer to two decimal places.

Example:

Input:

transactions table

Column Type
id INTEGER
user_id INTEGER
created_at DATETIME
product_id INTEGER
quantity INTEGER

users table

Column Type
id INTEGER
name VARCHAR
sex VARCHAR

products table

Column Type
id INTEGER
name VARCHAR
price FLOAT

Output:

Column Type
sex VARCHAR
aov FLOAT
Next question: Shortest Transformation
.....
Loading editor
Use Shift + Enter to run

Comments

Loading comments