Top Customers by Spend
Programming Interview
Easy
6 views
Problem Description
Tables: Orders(order_id, customer_id, total_amount, created_at). Return customer_id and total spend, sorted by spend desc.
Input Format
SQL tables are described in the question.
Output Format
Write the SQL query.
Official Solution
SELECT customer_id, SUM(total_amount) AS total_spend
FROM Orders
GROUP BY customer_id
ORDER BY total_spend DESC;
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!