Practice-first SQL repository · Built for long-term interview readiness
A personal SQL practice bank designed to retain fluency through continuous hands-on problem solving.
This repository does not teach SQL concepts.
It exists to practice them — the same way LeetCode problems strengthen logic after learning fundamentals.
| Step | Action |
|---|---|
| 1️⃣ | Revise SQL fundamentals (notes / docs / videos) |
| 2️⃣ | Open a .sql file from this repo |
| 3️⃣ | Comment out the solution |
| 4️⃣ | Solve the problem yourself |
| 5️⃣ | Compare & optimize |
Each file is a problem sheet, not a walkthrough.
One-glance rules to reset your brain before writing queries
-
All non-aggregated columns in
SELECTmust appear inGROUP BY
(but not allGROUP BYcolumns must appear inSELECT) -
Columns inside aggregate functions do NOT need to be in
GROUP BY -
You cannot use aggregate functions in
WHERE
→ useHAVINGinstead -
Query execution order: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY
-
Each group produces exactly one row in the result
-
Aggregate functions return one value per group
-
Aggregate functions ignore NULL values
(exceptCOUNT(*)) -
You cannot mix aggregated and non-aggregated columns in
SELECT
withoutGROUP BY
| Tool | Usage |
|---|---|
| 🗄️ Database | MySQL |
| 🧪 Execution | MySQL Workbench / compatible clients |
| 🎯 Focus | Query logic, edge cases, interview thinking |
SELECT,DISTINCTWHEREclauseORDER BY,LIMIT,OFFSET- Filtering using
IN,BETWEEN,LIKE,IS NULL - Conditional filtering patterns
COUNT,SUM,AVG,MIN,MAXGROUP BYHAVING- Conditional aggregations
- Multi-column grouping logic
INNER JOINLEFT JOIN,RIGHT JOINSELF JOIN- Multi-table joins
- Join conditions vs filter conditions
- Handling NULLs in joins
- Subqueries in
SELECT,WHERE, andFROM - Nested subqueries
- Correlated subqueries
EXISTS/NOT EXISTS- Subqueries vs joins
ROW_NUMBER()RANK()/DENSE_RANK()PARTITION BY- Ranking and ordering logic
- Nth highest value problems
- Top-N per group queries
CASE WHEN- Conditional aggregations
- Multi-condition branching
- Categorization and bucketing problems
- Date filtering
- Time-based grouping
- Difference between dates
- Month / year level aggregations
- Edge cases in date logic
- Duplicate detection
- Consecutive records
- Gap analysis
- Rolling calculations
- Multi-step query breakdowns
- Interview-driven logic building
✅ Practice-oriented queries
✅ No concept explanations
✅ Solutions included only as reference
✅ Optimized for re-solving
- Maintain long-term SQL muscle memory
- Avoid last-minute interview panic
- Improve query speed & accuracy
- Practice real-world interview logic
This repository was built using publicly available learning material for practice and problem exposure.
Special reference:
- The Grand Complete Data Science Materials – MySQL Interview Section
https://github.com/krishnaik06/The-Grand-Complete-Data-Science-Materials/tree/main/Complete%20MySQL%20Interview%20Materials
All problems are re-solved independently and organized for long-term interview preparation.
