Solving 50 SQL problems on LeetCode β from basic JOINs to advanced window functions.
Clean, well-commented solutions organised by concept. Updated daily.
SQL is tested in almost every Data Analyst, ML Engineer, and Backend role interview.
This repo is my structured practice log β each solution includes the problem link, approach, and clean query.
| # | Problem | Difficulty | Concept | Solution |
|---|---|---|---|---|
| 1 | Combine Two Tables | π’ Easy | LEFT JOIN | View |
| 2 | Second Highest Salary | π‘ Medium | LIMIT + OFFSET | View |
| 3 | Nth Highest Salary | π‘ Medium | Stored Function | View |
| 4 | Rank Scores | π‘ Medium | DENSE_RANK | View |
| 5 | Consecutive Numbers | π‘ Medium | Self JOIN | View |
π More problems being added daily β check back soon!
β
JOINs β INNER, LEFT, RIGHT, SELF JOIN
β
Window Funcs β RANK, DENSE_RANK, ROW_NUMBER
β
Subqueries β Scalar, Correlated, IN / NOT IN
π² Aggregations β GROUP BY, HAVING, COUNT, SUM
π² String Funcs β CONCAT, SUBSTRING, LIKE
π² Date Funcs β DATEDIFF, DATE_FORMAT, NOW()
π² CTEs β WITH clause, recursive queries
π² NULL Handling β IFNULL, COALESCE, IS NULL
- Database: MySQL (LeetCode environment)
- Tools: LeetCode SQL Editor, VS Code
- Language: Standard SQL with MySQL-specific functions
sql-50/
βββ Combine Two Tables # LEFT JOIN basics
βββ Second Highest Salary # LIMIT + OFFSET / subquery
βββ Nth Highest Salary # Stored function + LIMIT
βββ Rank Scores # DENSE_RANK window function
βββ Consecutive Numbers # Self JOIN technique
βββ README.md
- Click any problem file to see the SQL solution
- Each file has the query + a short comment explaining the approach
- Try solving it yourself first on LeetCode before reading!
Madhura Bhat β B.Tech AI & Data Science | Actively seeking Data/ML/GenAI roles
β If this helped you, consider starring the repo!