← All Assignments
Orders + Customers JOIN Queries
Problem Statement
Write SQL queries for an e-commerce schema with two tables: customers(id, name, email, city) orders(id, customer_id, product, amount, order_date) Write queries to: 1. List all orders with customer name and city 2. Find total amount spent per customer (only customers who ordered) 3. Find customers who have NOT placed any orders
Sample Data
customers: (1,'Alice','alice@x.com','Mumbai'), (2,'Bob','bob@x.com','Delhi'), (3,'Carol','carol@x.com','Pune') orders: (1,1,'Laptop',50000,'2024-01-10'), (2,1,'Mouse',1500,'2024-01-15'), (3,2,'Keyboard',3000,'2024-02-01')
Expected Output
Q1: Alice-Mumbai-Laptop, Alice-Mumbai-Mouse, Bob-Delhi-Keyboard Q2: Alice=51500, Bob=3000 Q3: Carol