Customers
CustomerID | CustomerName | City | Phone
-----------|--------------|------------|-------------
1 | Ravi Kumar | Hyderabad | 9876543210
2 | Priya Sharma | Bangalore | 9123456780
3 | John Doe | Chennai | 9345671234s
4 | Amit Singh | Hyderabad | 9456789012
Restaurants
RestaurantID | RestaurantName | City | CuisineType
-------------|----------------|------------|------------
101 | Biryani House | Hyderabad | Indian
102 | Pizza Palace | Bangalore | Italian
103 | Tandoor Treats | Chennai | Indian
104 | Sushi World | Hyderabad | Japanese
Orders
OrderID | CustomerID | RestaurantID | OrderDate | TotalAmount
--------|------------|--------------|-------------|------------
1001 | 1 | 101 | 2025-08-25 | 800.00
1002 | 2 | 102 | 2025-08-26 | 1200.00
1003 | 3 | 103 | 2025-08-27 | 500.00
1004 | 1 | 104 | 2025-08-28 | 1500.00
1005 | 4 | 101 | 2025-08-29 | 600.00
OrderItems
ItemID | OrderID | ItemName | Quantity | Price
-------|---------|------------------|----------|--------
1 | 1001 | Chicken Biryani | 2 | 400.00
2 | 1002 | Veg Pizza |2 | 600.00
3 | 1003 | Paneer Tikka |1 | 500.00
4 | 1004 | Sushi Platter | 3 | 500.00
5 | 1005 | Mutton Biryani | 1 | 600.00
Here are some basic SQL questions based on your schema and data
1. Write a query to display all customer names and their cities.
2. Retrieve the names of all restaurants located in Hyderabad.
3. Find all orders placed by the customer "Ravi Kumar".
4. List the item names and quantities ordered in order 1001.
5. Get the total number of customers in the database.
6. Display all restaurants serving "Indian" cuisine.
7. Find the total amount spent by customer with CustomerID = 1.
8. List all orders placed after 2025-08-26.
9. Show the names of customers who ordered from "Pizza Palace".
10. Retrieve all unique cities where restaurants are located.
11. Find the maximum total amount among all orders.
12. Display the customer name and phone number for customer ID = 3.
13. Count the total number of orders placed from Hyderabad restaurants.
14. Show the names of all food items ordered along with their prices.
15. List all restaurants along with their cuisine types in ascending order of name.
16. Retrieve the order IDs and total amounts where the total amount is greater than 1000.
17. Find the restaurant name and city for restaurant ID = 104.
18. Display all order items where the quantity is greater than 1.
19. Show all customers who placed orders in Hyderabad restaurants.
20. Retrieve all orders along with the corresponding customer names.
Here’s a set of intermediate SQL questions (joins, group by, subqueries, having, etc.) based on your
schema.
1. List each customer along with the total number of orders they have placed.
2. Find the total revenue generated by each restaurant.
3. Retrieve the top 2 customers who spent the most money overall.
4. Display the restaurant names along with the average order amount for each.
5. Find all customers who have ordered from more than one restaurant.
6. Show the most expensive item ordered by each customer.
7. Get the total quantity of items sold by each restaurant.
8. Find the restaurants that received orders from customers living in the same city as the
restaurant.
9. Display all customers who have never placed an order.
10. Retrieve the order IDs where the total amount is greater than the average order amount.
11. Find which cuisine type generated the highest total revenue.
12. For each order, show the number of items included in it.
13. Display all restaurants that haven’t received any orders.
14. Show the customer name and their last order date.
15. Find all orders where more than 2 items were ordered (sum of quantities > 2).
16. Display customers and the total amount they spent, but only include those who spent more
than 1000.
17. List all items ordered by customers in Hyderabad.
18. Show the restaurant with the maximum number of unique customers.
19. Retrieve the names of customers who ordered “Biryani” (in any item name).
20. Find the total revenue generated per city (based on restaurant’s city).