How to Learn SQL in 30 Days for Data Analyst Interviews β Day-by-Day Plan
SQL is useful for querying relational data. This plan introduces its core concepts and gives you a structure for daily practice.
This guide gives you a complete day-by-day plan β not vague topics, but exact things to do each day β plus free resources to practice in a live SQL compiler starting from day one.
SELECT product, SUM(revenue) FROM sales GROUP BY product gives total revenue per product.The 30-Day SQL Learning Plan
| Days | Topic | What to Master | Practice Goal |
|---|---|---|---|
| Days 1β3 | SELECT Basics | SELECT, WHERE, ORDER BY, LIMIT, DISTINCT, aliases | Write 10 basic SELECT queries without help |
| Days 4β6 | Aggregations | COUNT, SUM, AVG, MIN, MAX, GROUP BY, HAVING | Solve 10 GROUP BY questions, explain WHERE vs HAVING |
| Days 7β10 | SQL JOINs | INNER, LEFT, RIGHT, FULL OUTER, anti-join pattern | Write all 4 JOIN types + find records with no match |
| Days 11β14 | Subqueries & CTEs | Subquery in WHERE/FROM, WITH clause, CTE chaining | Rewrite 3 nested subqueries as CTEs |
| Days 15β20 | Window Functions | RANK, DENSE_RANK, ROW_NUMBER, LAG, LEAD, SUM OVER | Solve top-N-per-group, month-over-month growth |
| Days 21β24 | Date & String Functions | DATEDIFF, EXTRACT, SUBSTR, CONCAT, COALESCE | Write 5 date-based queries from real interview banks |
| Days 25β28 | Interview Practice Questions | Interview-style questions across SQL topics | Timed practice: 30 min per question, no hints |
| Days 29β30 | Mock + Review | Full mock SQL interview session + gap review | Complete 1 full mock interview, identify weak areas |
Days 1β10: SQL Foundations
This foundation block introduces filtering, grouping, and joins. Practise these before moving to multi-stage queries.
Days 1β3: SELECT and Filtering
Days 4β6: GROUP BY and Aggregations
GROUP BY is the most commonly tested SQL concept in entry-level interviews. The single most important thing to understand: every column in SELECT must either be in GROUP BY or be an aggregate function.
Days 7β10: All JOIN Types
JOINs combine related records across tables. The most important pattern to master is the anti-join β finding records in one table that have no match in another. This is asked constantly: “customers who never ordered”, “products never purchased”, “users with no logins last 30 days”.
Days 11β20: Advanced SQL
Days 11β14: CTEs β Write Cleaner SQL
CTEs (Common Table Expressions) use the WITH keyword to name a subquery. They make complex SQL dramatically more readable and are strongly preferred over nested subqueries in interviews.
Days 15β20: Window Functions β The Game Changer
Window functions calculate values across related rows while preserving each row. Practise ranking, comparing consecutive records, and running totals.
| Function | What it does | Classic Interview Question |
|---|---|---|
RANK() | Rank with gaps on ties | Top-N employees per department |
ROW_NUMBER() | Always unique rank | Exactly 1 record per group |
DENSE_RANK() | Rank without gaps | 2nd highest salary (no gaps) |
LAG(col, n) | Value from N rows before | Month-over-month growth % |
LEAD(col, n) | Value from N rows ahead | Days until next purchase |
SUM() OVER() | Running/cumulative total | Cumulative revenue by date |
Days 21β30: Interview Practice
The final 10 days are about performance, not learning. You should no longer be learning new concepts β you should be practising speed, accuracy and thinking out loud.
Days 21β24: Timed question practice
Pick 2β3 questions daily from the 50+ question bank at dataanalystinterview.com/sql-top-question/. Set a 25-minute timer per question. If you get stuck after 10 minutes, look at the hint β not the full answer.
Days 25β26: Company-specific prep
Research your target company. If it’s Flipkart, focus on window functions and business case queries. If it’s TCS or Infosys, easy-to-medium GROUP BY questions are the focus. Tailor your practice.
Days 27β28: Weak area drilling
From your 20+ days of practice, you know what trips you up. Spend 2 full days on only your weak spots. Most people need extra time on CTEs or consecutive-day window function tricks.
Days 29β30: Full mock interview
Book a mock SQL interview session. Write queries live, explain your reasoning out loud, handle feedback. The difference between practising alone and performing in an interview is massive.
β Key Takeaways
- Use 30 days as a suggested schedule with 1β2 hours daily β basics in week 1, advanced in weeks 2β3, practice in week 4
- Days 1β10 cover foundational query patterns β GROUP BY, JOINs and basic aggregations
- Days 15β20 on window functions is your biggest differentiator β practise these on small datasets
- The anti-join pattern (LEFT JOIN + WHERE IS NULL) is useful for finding unmatched records β practise it
- Days 29β30: do a live mock interview β writing SQL under observation reveals habits reading cannot
- All resources needed are free: SQL Hub with live compiler at dataanalystinterview.com/sql-interview/
Start Day 1 right now β free
Our SQL Hub has all 8 topics, worked examples and a live SQL compiler with pre-loaded tables. No account, no download.
Start SQL Learning Free βDocumentation and next steps
Check the relevant documentation for your software version and database dialect. These are practice resources, not verified employer question banks.
Find a related learning guide Β· About the author Β· Suggest a correction
