Skip to content
C

Total Revenue by Region

Easysql
Learn the Concept: GROUP BY

Write a query returning region and total (sum of amount) for each region, ordered by region.

sql
CREATE TABLE orders ( id INTEGER PRIMARY KEY, region TEXT NOT NULL, product TEXT NOT NULL, amount INTEGER NOT NULL );

Sample data:

sql
INSERT INTO orders (id, region, product, amount) VALUES (1, 'North', 'Widget', 200), (2, 'North', 'Gadget', 150), (3, 'South', 'Widget', 100), (4, 'South', 'Gadget', 50), (5, 'North', 'Widget', 300), (6, 'East', 'Widget', 400);

Related Problems

Input (stdin)

Output

Run your code to see output here...