Skip to content
C

Price Tiers

Mediumsql

Write a query returning id, name, and a computed tier column: 'Budget' if price < 300, 'Mid' if price is between 300 and 1000 inclusive, otherwise 'Premium'. Order by id.

sql
CREATE TABLE products ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, category TEXT NOT NULL, price INTEGER NOT NULL, stock INTEGER );

Sample data:

sql
INSERT INTO products (id, name, category, price, stock) VALUES (1, 'ProLaptop', 'Electronics', 85000, 12), (2, 'Notebook', 'Stationery', 40, NULL), (3, 'Python Basics', 'Books', 350, 5), (4, 'ProPhone', 'Electronics', 45000, 0), (5, 'Novel', 'Books', 220, NULL), (6, 'Desk Lamp', 'Home', 900, 8);

Input (stdin)

Output

Run your code to see output here...