Largest order totals
hardShow the three largest order totals with order id, total amount, and rank. Resolve ties by order id and return exactly three rows.
Hospital Database · SQLite
Run your SQL answer to see the returned rows and check it.
SELECT order_id, total_amount, order_rank FROM (SELECT order_id, total_amount, ROW_NUMBER() OVER (ORDER BY total_amount DESC, order_id) AS order_rank FROM orders) WHERE order_rank <= 3 ORDER BY order_rank;