Two weeks is enough to prepare for a Junior/Middle SQL interview. Here's a step-by-step plan.
Week 1: Fundamentals
Day 1-2: SELECT, WHERE, ORDER BY
The foundation. Make sure you can write queries with filtering, sorting, LIKE, IN, BETWEEN, IS NULL.
Day 3-4: JOIN
The most common interview topic. Practice INNER, LEFT, RIGHT JOIN. Make sure to understand SELF JOIN.
Day 5: GROUP BY + HAVING
Aggregate functions: COUNT, SUM, AVG, MIN, MAX. Difference between WHERE and HAVING.
Day 6-7: Subqueries and CTE
Nested SELECT in WHERE, FROM, SELECT. Common Table Expressions (WITH).
Week 2: Advanced Topics
Day 8-9: Window Functions
ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, SUM OVER. This is what separates Middle from Junior.
Day 10: Date Operations
Extracting date parts, date differences, grouping by months/quarters.
Day 11: Optimization
EXPLAIN, indexes, EXISTS vs IN, why SELECT * is bad practice.
Day 12-13: Practice Real Problems
Solve problems on SQL Trainer, LeetCode, HackerRank. Minimum 5-10 problems per day.
Day 14: Review
Revisit all problems that were difficult. Prepare theoretical answers:
- What is normalization? (1NF, 2NF, 3NF)
- What is an index and how does it work?
- ACID transaction properties
- DELETE vs TRUNCATE
- Transaction isolation levels
Common Interview Mistakes
- Not testing edge cases — what if the table is empty? NULLs?
- Writing unoptimized queries — SELECT * instead of specific columns
- Not explaining the solution — interviewers want to understand your thought process
Resources
- SQL Trainer — 500+ problems with instant verification
- LeetCode Database — problems from real companies
- PostgreSQL documentation — best SQL reference