SQL foundations: three drills
Target skills:
- SELECT/FROM/WHERE
- ORDER BY/LIMIT
- basic GROUP BY
Easy #
Return the top 5 highest-value orders. Output exactly id, user_id, and total, sorted by total descending. Two orders share the same total at the cutoff, so break ties by id ascending.
Loading SQL editor...
Medium #
For each product_id, return the order count as order_count and total revenue as revenue, rounded to 2 decimals with ROUND(SUM(total), 2). Sort highest revenue first and return the top 10 rows (LIMIT 10). Output exactly product_id, order_count, revenue.
Loading SQL editor...
Hard #
Find users with at least 2 orders and average order value >= 100 (apply both thresholds to the unrounded average). Output exactly user_id, the order count as orders, and the average order value as avg_order_value rounded to 2 decimals, sorted by avg_order_value descending.
Loading SQL editor...