Back to Blog
SQL

SQL Crash Course: From Zero to Interview-Ready in 30 Days

Vajo Lukic
June 20, 2026
8 min read
SQL Crash Course: From Zero to Interview-Ready in 30 Days

Learning SQL doesn't have to take months. A focused 30-day crash course gets you from zero to competent — able to write real queries, pass technical interviews, and work with databases confidently.

This guide is your SQL crash course: a day-by-day learning path with the core concepts, SQL examples, and practice exercises you actually need.

Who This Is For

This crash course works for:

  • Complete beginners who've never written a SQL query
  • Developers who know another language but need to learn database querying
  • Data analysts switching from Excel to SQL-backed BI tools
  • Job seekers preparing for a data or backend role

You don't need to know any programming. You need a computer and 45–60 minutes a day.

What You'll Learn in 30 Days

Phase Days Topics
Foundations 1–7 Databases, tables, SELECT, WHERE, ORDER BY
Core SQL 8–15 JOINs, GROUP BY, aggregation, subqueries
Intermediate 16–22 CTEs, window functions, NULL handling
Advanced 23–28 Query optimization, indexes, real databases
Interview Prep 29–30 Pattern review, mock questions, strategy

Week 1: SQL Foundations (Days 1–7)

Day 1–2: Your First Queries

SQL is about asking questions of a database. Every query starts with SELECT:

-- Get all rows from a table
SELECT * FROM customers;

-- Get specific columns
SELECT customer_id, name, email FROM customers;

-- Filter rows
SELECT name, email
FROM customers
WHERE country = 'USA';

The execution order matters: FROM runs first, then WHERE, then SELECT. Understanding this prevents a lot of beginner mistakes.

Day 3–4: Filtering and Sorting

-- Multiple conditions
SELECT product_name, price
FROM products
WHERE category = 'Electronics'
  AND price < 500
ORDER BY price ASC;

-- Pattern matching
SELECT name FROM customers
WHERE email LIKE '%@gmail.com';

-- Range filtering
SELECT order_id, total
FROM orders
WHERE order_date BETWEEN '2026-01-01' AND '2026-03-31';

Day 5–7: Aggregation

-- Count, sum, average per group
SELECT
    category,
    COUNT(*) AS product_count,
    AVG(price) AS avg_price,
    MIN(price) AS cheapest,
    MAX(price) AS most_expensive
FROM products
GROUP BY category
HAVING COUNT(*) > 5
ORDER BY avg_price DESC;

GROUP BY groups rows. HAVING filters groups — like WHERE but applied after grouping. Don't confuse them.


Week 2: Core SQL (Days 8–15)

Day 8–11: JOINs

JOINs combine data from multiple tables. This is where SQL becomes powerful.

-- INNER JOIN: only matching rows from both tables
SELECT o.order_id, c.name, o.total
FROM orders o
INNER JOIN customers c ON o.customer_id = c.customer_id;

-- LEFT JOIN: all rows from the left table, NULLs where no match
SELECT c.name, o.order_id, o.total
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id;

Key rule: INNER JOIN returns only rows that match in both tables. LEFT JOIN returns all rows from the left table, even without a match on the right. Mixing these up is the most common SQL bug.

For a full reference with all join types and visual diagrams, see SQL Joins Explained.

Day 12–15: Subqueries

-- Subquery in WHERE: employees earning above average
SELECT name, salary
FROM employees
WHERE salary > (SELECT AVG(salary) FROM employees);

-- Subquery in FROM: derived table
SELECT department, avg_salary
FROM (
    SELECT department, AVG(salary) AS avg_salary
    FROM employees
    GROUP BY department
) dept_summary
WHERE avg_salary > 80000;

Week 3: Intermediate SQL (Days 16–22)

Day 16–18: CTEs (Common Table Expressions)

CTEs make complex queries readable. They're named temporary result sets defined before the main query:

WITH high_value_customers AS (
    SELECT customer_id, SUM(total) AS lifetime_value
    FROM orders
    GROUP BY customer_id
    HAVING SUM(total) > 10000
),
active_customers AS (
    SELECT customer_id, name, country
    FROM customers
    WHERE status = 'active'
)
SELECT ac.name, ac.country, hvc.lifetime_value
FROM active_customers ac
JOIN high_value_customers hvc ON ac.customer_id = hvc.customer_id
ORDER BY hvc.lifetime_value DESC;

Day 19–22: Window Functions

Window functions perform calculations across rows without collapsing them into one — unlike GROUP BY. They're essential for analytics and a common interview topic.

-- Rank employees by salary within each department
SELECT
    name,
    department,
    salary,
    RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS dept_rank
FROM employees;
-- Running total of daily sales
SELECT
    sale_date,
    amount,
    SUM(amount) OVER (ORDER BY sale_date) AS running_total
FROM sales;

For a complete reference with 9 essential patterns, see the SQL Window Functions Guide.


Week 4: Advanced SQL (Days 23–28)

Day 23–25: Query Optimization

Understanding why a query is slow is worth more than knowing any specific syntax.

-- PostgreSQL: check how the database plans to execute your query
EXPLAIN ANALYZE
SELECT * FROM orders WHERE customer_id = 12345;

Key concepts:

  • Indexes speed up lookups on filtered columns — without one, the database scans every row
  • Covering indexes include all columns a query needs, avoiding secondary table lookups
  • Seq scan vs index scan — a sequential scan on a 10M-row table is slow; an index scan is fast

For techniques that move queries from 3 seconds to 30 milliseconds, see the SQL query optimization guide.

Day 26–28: Practice on Real Schemas

Work with a real database schema, not toy examples. Practice these problems until they're automatic:

  1. Find the top 3 customers by revenue per country
  2. Calculate month-over-month growth as a percentage
  3. Find duplicate rows and keep only the most recent

These are real interview problems. If you can solve them from scratch, you're ready.


Days 29–30: Interview Prep

Most Common SQL Interview Patterns

Deduplication — keep the latest record per user:

SELECT user_id, email, created_at
FROM (
    SELECT *,
           ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY created_at DESC) AS rn
    FROM users
) t
WHERE rn = 1;

Top-N per group:

-- Top 2 products by sales per category
SELECT category, product, total_sales
FROM (
    SELECT
        category,
        product,
        total_sales,
        DENSE_RANK() OVER (PARTITION BY category ORDER BY total_sales DESC) AS dr
    FROM product_sales
) t
WHERE dr <= 2;

Cohort analysis:

-- Users who signed up in Jan 2026 and ordered within 30 days
SELECT COUNT(DISTINCT u.user_id)
FROM users u
JOIN orders o ON u.user_id = o.user_id
WHERE u.signup_date >= '2026-01-01'
  AND u.signup_date < '2026-02-01'
  AND o.order_date <= u.signup_date + INTERVAL '30 days';

Practice these until you can write them without looking.


What to Practice On

You need a real database to query:

  • PostgreSQL locally — install, create a schema, load sample data
  • SQLiteOnline.com — runs SQL in the browser, no setup
  • LeetCode SQL — interview-style problems with real schemas
  • HackerRank SQL — structured challenges by difficulty

Frequently Asked Questions

How long does it take to learn SQL for a job?

With 45–60 minutes of daily practice, you can reach job-ready SQL competency in 4–6 weeks. The core skill set — SELECT, JOINs, aggregation, subqueries, CTEs, window functions — covers 90% of what any data or backend role requires. The remaining 10% (advanced optimization, database-specific features) comes from on-the-job experience.

What SQL should I learn first?

Start with SELECT, WHERE, ORDER BY, and GROUP BY. These cover the core data retrieval pattern. Then learn JOINs (inner and left). Then CTEs and window functions. This order mirrors how interviews test SQL — fundamentals first, analytics second. Don't skip ahead to window functions before you're fluent with GROUP BY.

Is SQL hard to learn?

SQL is one of the most learnable technical skills. The syntax reads close to English ("SELECT name FROM users WHERE country = 'USA'"), and the core operations — filter, sort, group, join — map to things you already do in spreadsheets. The hard part is developing set-based thinking: SQL operates on sets of rows, not individual values. That mental model shift takes a week or two; the syntax takes a day.

Which SQL dialect should I learn?

Learn standard SQL first — the core is the same across all databases. When you specialize: PostgreSQL for web and data engineering (most common in job postings), BigQuery or Snowflake for data warehousing, MySQL for web development. If you know the fundamentals, switching dialects takes days, not weeks.


Want all of this in one place, with 350+ examples and 140+ interview questions? The SQL Crash Course book covers everything from this guide — plus query optimization, transactions, data modeling, and full interview prep — in 270+ pages built for working through in 30 days.

Have questions about the learning path or SQL concepts you're stuck on? Get in touch.

#sql#beginners#learning#career#interview#crash-course#sql-basics

Enjoyed this article? Share it!

About the Author

VL

Vajo Lukic

Vajo Lukic is a technology leader with 20+ years of experience in software development and system administration. Author of The Practical Linux Handbook, he shares practical, field-tested knowledge to help developers and IT professionals master Linux fundamentals.

Read more about Vajo

Related Articles

10 Essential SQL Queries Every Developer Should Know (With Examples)

10 Essential SQL Queries Every Developer Should Know (With Examples)

The 10 SQL query patterns every developer needs: SELECT, JOINs, GROUP BY, CTEs, window functions, and more. With real examples and performance tips.

Read more →
ChatGPT Can't Replace Your SQL Skills — Here's Why

ChatGPT Can't Replace Your SQL Skills — Here's Why

ChatGPT generates SQL, but it doesn't know your schema, can't optimize for your indexes, and gets NULL handling wrong. Here's what AI still can't do with SQL.

Read more →
Is SQL Still Relevant in 2026? SQL in the Age of LLMs

Is SQL Still Relevant in 2026? SQL in the Age of LLMs

SQL is more valuable than ever in the LLM era. Here's why data professionals still need SQL even with AI tools like ChatGPT and Copilot.

Read more →

Ready to Transform Your Life?

Get the complete guide to personal transformation and start your journey today.

Get the Book