Top customer by total spend

SQL Medium 3 views
Back to Questions

Problem Description

From Orders(customer_id, total_amount), find the customer who spent the most overall. First do SUM per customer, then pick the highest one.

Input Format

SQL query

Output Format

Result set

Sample Test Case

Input:
Orders(customer_id, total_amount)
Output:
Top customer row

Constraints

Think: GROUP BY customer_id then ORDER BY SUM desc

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next