← Back to SQL Track
Reference
SQL Cheat Sheet
Every syntax pattern from all 62 lessons, on one page. Bookmark this before your interview.
Basic SELECT
Filtering — WHERE
Sorting & Grouping
CRUD Operations
Joins
Subqueries & Set Ops
Window Functions
CTEs & Advanced
Performance
Projects to build
The fastest way to make this stick. Build one, then put it in your portfolio.
Beginner
FreshCart questions
Answer ten questions about the FreshCart tables with SELECT, WHERE, ORDER BY, and LIMIT. Write the question as a comment above each query.
SELECTWHEREORDER BY
Beginner
Customer rollup
One query per customer: order count, total spent, and the date of the last order. Customers with no orders still appear.
JOINGROUP BYLEFT JOIN
Intermediate
Top products by city
Rank products inside each city by revenue. Return only the top three per city.
JOINwindow functionsRANK
Intermediate
Month-over-month
Revenue by month, plus the previous month and the change, using LAG. Explain one month where the number moved.
aggregationLAGCTE
Advanced
Slow query, then an index
Take a filter-and-join query, read EXPLAIN, add one index that matches the filter, and show the plan again.
EXPLAINindexestransactions
Ready to go deeper?
Start from Lesson 01 and learn every concept with real queries and the FreshCart database.
