1.Revenue by region
IntermediateFor each region, return the total amount as revenue and the number of sales as sales. Show the highest revenue first.
Show hint
GROUP BY region, with SUM and COUNT in the SELECT.
Show solution
SELECT region,
SUM(amount) AS revenue,
COUNT(*) AS sales
FROM sales
GROUP BY region
ORDER BY revenue DESC;region | revenue | sales
-------+---------+------
North | 320000 | 5
South | 160000 | 3
East | 85000 | 2