Easy. List product names and prices in product-id order. Target: 6 rows; Notebook is 100.00 and Planner is 300.00.
SELECT product_name, price FROM products ORDER BY product_id;
Medium. Find products costing at least 300, most expensive first. Target: Keyboard, Desk lamp, Planner, in that order.
SELECT product_name, price FROM products WHERE price >= 300 ORDER BY price DESC, product_id;
Hard. Find customers whose email is missing. Target: Only Charu, customer_id 3. Explain why = NULL is wrong.
SELECT customer_id, customer_name FROM customers WHERE email IS NULL;
Professional. Prepare a stable two-row extract for a customer service team. Target: First page ids 1,2; second page 3,4. Document that offset pages can shift when source data changes.
SELECT customer_id, customer_name, city FROM customers ORDER BY customer_id LIMIT 2 OFFSET 0;
SELECT customer_id, customer_name, city FROM customers ORDER BY customer_id LIMIT 2 OFFSET 2;
Easy. List all customers from Mumbai. Target: 2 rows: (2, Bilal); (5, Esha)
SELECT customer_id, customer_name FROM customers WHERE city = 'Mumbai' ORDER BY customer_id;
Easy. List products in the Stationery category. Target: 3 rows: (Notebook, 100.00); (Pen, 20.00); (Planner, 300.00)
SELECT product_name, price FROM products WHERE category = 'Stationery' ORDER BY product_id;
Easy. List all cancelled orders. Target: 1 row: order_id = 104, customer_id = 3
SELECT order_id, customer_id FROM orders WHERE status = 'cancelled';
Easy. List products sorted by name A to Z. Target: 6 rows: Desk lamp, Keyboard, Mug, Notebook, Pen, Planner
SELECT product_name FROM products ORDER BY product_name;
Medium. List products cheaper than 300. Target: 3 rows: (Pen, 20.00); (Notebook, 100.00); (Mug, 250.00)
SELECT product_name, price FROM products WHERE price < 300 ORDER BY price;
Medium. List orders that are not completed. Target: 2 rows: (104, cancelled); (107, pending)
SELECT order_id, status FROM orders WHERE status <> 'completed' ORDER BY order_id;
Medium. List Stationery products costing more than 50. Target: 2 rows: (Notebook, 100.00); (Planner, 300.00)
SELECT product_name, price FROM products WHERE category = 'Stationery' AND price > 50 ORDER BY product_id;
Medium. List customers from Pune or Delhi. Target: 3 rows: (Asha, Pune); (Charu, Pune); (Dev, Delhi)
SELECT customer_name, city FROM customers WHERE city = 'Pune' OR city = 'Delhi' ORDER BY customer_id;
Medium. List customers who do have an email. Target: 5 rows: everyone except Charu
SELECT customer_name, email FROM customers WHERE email IS NOT NULL ORDER BY customer_id;
Hard. List customers sorted by city, then by name within each city. Target: 6 rows: (Dev, Delhi); (Farah, Jaipur); (Bilal, Mumbai); (Esha, Mumbai); (Asha, Pune); (Charu, Pune)
SELECT customer_name, city FROM customers ORDER BY city, customer_name;
Hard. Show each product with a new column price_with_gst = price * 1.18. Target: 6 rows; Notebook 118.00, Pen 23.60, Desk lamp 944.00, Mug 295.00, Keyboard 1416.00, Planner 354.00
SELECT product_name, price, price * 1.18 AS price_with_gst FROM products ORDER BY product_id;
Hard. Find Electronics products OR any product under 50, and explain the brackets in: category = 'Home' AND (price < 300 OR price > 1000). Target: 3 rows: Pen, Desk lamp, Keyboard
SELECT product_name FROM products WHERE category = 'Electronics' OR price < 50 ORDER BY product_id;
Hard. Show all customers with the missing email replaced by the text 'no email' (preview of COALESCE). Target: 6 rows; Charu shows no email
SELECT customer_name, COALESCE(email, 'no email') AS email FROM customers ORDER BY customer_id;
Professional. Prepare the 2 most expensive products for a price-review meeting. Target: 2 rows: (Keyboard, 1200.00); (Desk lamp, 800.00)
SELECT product_name, price FROM products ORDER BY price DESC, product_id LIMIT 2;
Professional. Give the delivery team every completed order, newest first, with order_id and date only. Target: 6 rows: 108, 106, 105, 103, 102, 101
SELECT order_id, order_date FROM orders WHERE status = 'completed' ORDER BY order_date DESC;