Skip to content
C

High-Revenue Regions Only

Mediumsql
Learn the Concept: HAVING

Write a query returning region and total (sum of amount) only for regions whose total revenue exceeds 500, 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...