Home / SQL Tutorial / Day 12
Day 12 — Putting it together
No new syntax today. Twelve questions of the kind you get asked in an interview or on your first week at work — try each one before opening the answer.
How to use this page
Read the question, write your own query in the box, then press Run. The box already contains a working answer, so change it first and use ↺ to bring the answer back.
1. How many customers are in each state?
2. What is our total delivered revenue?
3. Which customer has spent the most?
4. Which customers have never ordered?
5. Month-by-month revenue
Our playground has no date functions, so group on the first 7 characters of the date — the trick still teaches the shape.
6. Average order value per sales rep, best first
7. Reps who closed more than 300000
8. Every employee with their manager
9. Headcount and salary cost per department
10. Top 3 products by units sold
11. Cancelled orders, with the customer to call
12. Full revenue report by city and category
Where to go next
You now know enough SQL to be useful in an analyst or MIS job. The next steps are window functions, CTEs, stored procedures and query tuning — all of which we cover on the SQL course in Noida, on a real SQL Server database rather than a browser playground.
Try these yourself
- Rewrite question 3 to show the top 3 customers instead of 1.
- Add the customer City to question 11.
- Change question 9 to show only departments with more than one person.
- Write a query that finds the single largest order line by value.
Want this taught properly?
This tutorial covers the basics. Our SQL course in Noida takes you through window functions, CTEs and stored procedures on a real database, with projects and mentor support.
See the SQL course →