Grouping
6 / 12
EasyOutput prediction

Sort grouped results by aggregate value

Given this table (orders):

idcustomeramount
1Alice100
2Bob400
3Alice200
4Carol150

What does this query return?

SELECT customer, SUM(amount) AS total FROM orders GROUP BY customer ORDER BY total DESC;

← → arrow keys to navigate

Sign in to save your progress.