Online SQL course: learn queries by writing them

Six levels that take you from your first SELECT to reports across several tables, with a project at the end of each level and a final test. You practice on a real database in your browser and get feedback straight away.

In short: this is a self-paced course with no instructor and no fixed dates. Each lesson explains one idea and then has you write queries that are checked on the spot. All of level 1 is free, and from level 2 on the first exercise of every lesson is free.

Try it now

Here is a real exercise from the course. The database belongs to a small online store selling office supplies, and the table you need is shown above the editor. Run shows your result, Check tells you whether it is right.

Task Sales is planning visits in Boston. From the customers table, show the columns name and phone, but only for customers whose city is Boston.

customers 12 rows, 7 columns
customer_idnamecitycountrycustomer_sincesegmentphone
1Harbor Fremont PartnersBostonUSA2021-03-15Business617-555-0142
2Emily CarterChicagoUSA2022-07-01ConsumerNULL
3Riverside County OfficeRiversideUSA2020-11-20Government951-555-0110
4Raj PatelLeedsUK2023-01-09Consumer0113 496 0123
5Lakeview Hotel LtdManchesterUK2022-04-18Business0161 496 0456
6Olivia BrooksAustinUSA2024-02-27ConsumerNULL
7Greene & Shaw LLPLondonUK2021-09-05Business020 7946 0321
8Maple Grove High SchoolAustinUSA2023-08-14School512-555-0187
9Chloe EvansBostonUSA2025-05-30Consumer617-555-0199
10Northline Printing CoTorontoCanada2020-06-12Business416-555-0133
11Daniel KimSeattleUSA2024-10-03ConsumerNULL
12Westbrook Dental ClinicChicagoUSA2022-12-01Business312-555-0164

Got it? You just filtered rows with WHERE. The lesson on SQL WHERE explains how the condition is evaluated and which mistakes trip up most beginners.

What the course covers

There are six levels. Each one ends with a project: a bigger task from everyday office work where you write several queries in a row and put the pieces together.

  • Level 1: Getting started. Tables, rows and columns, SELECT, WHERE, AND and OR, IN, BETWEEN, LIKE, missing values with NULL, ORDER BY, DISTINCT and calculated columns. Project: customer list.
  • Level 2: Summarizing data. COUNT, SUM, AVG, MIN and MAX, groups with GROUP BY and HAVING, CASE WHEN, string and date functions. Project: sales report.
  • Level 3: Joining tables. JOIN and LEFT JOIN, queries across several tables, self joins, UNION, subqueries and EXISTS. Project: order overview.
  • Level 4: Changing data and building tables. INSERT, UPDATE and DELETE, CREATE TABLE and ALTER TABLE, primary and foreign keys, views and transactions. Project: inventory.
  • Level 5: Advanced queries. WITH (CTEs), rankings with window functions, running totals, LAG and LEAD, pivoting with CASE WHEN and finding duplicates. Project: customer analysis.
  • Level 6: Real work and final test. The order in which a database runs your query, SQL for Excel users and the differences between MySQL, PostgreSQL and SQL Server. Project: monthly report, followed by the final test.

Your learning path

Lessons build on each other, but you can open any of them directly. With a free account your solved exercises are saved, and the check marks show your progress on every device.

  1. Level 1: Getting started

    1. Basics: tables, rows, columns 2 exercises
    2. SELECT: query columns 2 exercises
    3. WHERE: filter rows 3 exercises
    4. AND, OR, NOT 3 exercises
    5. IN and BETWEEN 3 exercises
    6. LIKE: pattern matching 3 exercises
    7. NULL and COALESCE 3 exercises
    8. ORDER BY and LIMIT 3 exercises
    9. DISTINCT: drop duplicates 2 exercises
    10. Calculations and column aliases 3 exercises
    11. Project: Customer list 2 exercises
  2. Level 2: Summarizing data

    1. COUNT: count rows 3 exercises
    2. SUM, AVG, MIN, MAX 3 exercises
    3. GROUP BY: summarize groups 3 exercises
    4. HAVING: filter groups 3 exercises
    5. CASE WHEN: conditional logic 3 exercises
    6. String functions 3 exercises
    7. Dates and times 3 exercises
    8. Project: Sales report 2 exercises
  3. Level 3: Joining tables

    1. INNER JOIN: joining tables 3 exercises
    2. LEFT JOIN 3 exercises
    3. Joining multiple tables 3 exercises
    4. Self join 3 exercises
    5. UNION 3 exercises
    6. Subqueries 3 exercises
    7. EXISTS and NOT EXISTS 3 exercises
    8. Project: Order overview 2 exercises
  4. Level 4: Changing data and building tables

    1. INSERT: adding rows 3 exercises
    2. UPDATE: changing rows 3 exercises
    3. DELETE: removing rows 3 exercises
    4. CREATE TABLE 3 exercises
    5. ALTER TABLE 3 exercises
    6. Primary and foreign keys 3 exercises
    7. Views 3 exercises
    8. Transactions 3 exercises
    9. Project: Inventory 2 exercises
  5. Level 5: Advanced queries

    1. WITH (CTE) 3 exercises
    2. Window functions: ROW_NUMBER, RANK 3 exercises
    3. Running totals and shares 3 exercises
    4. LAG and LEAD 3 exercises
    5. Pivot with CASE WHEN 3 exercises
    6. Finding duplicates 3 exercises
    7. Project: Customer analysis 2 exercises
  6. Level 6: Real work and final test

    1. Order of execution 3 exercises
    2. SQL for Excel users 3 exercises
    3. MySQL, PostgreSQL, SQL Server 3 exercises
    4. Project: Monthly report 2 exercises
    5. SQL final testcertificate after levels 1 to 5
  7. Bonus: Database design

    2 lessons, Bonus, not needed for the certificate
    1. Normalization 3 exercises
    2. ER diagrams and table design 3 exercises
  8. Bonus: Performance

    2 lessons, Bonus, not needed for the certificate
    1. Indexes 3 exercises
    2. EXPLAIN: understanding queries 3 exercises
  9. Bonus: Recursive queries and upserts

    2 lessons, Bonus, not needed for the certificate
    1. Recursive queries 3 exercises
    2. UPSERT: insert or update 3 exercises

Start with lesson 1 Create a free account

How practicing in the browser works

Every exercise runs against a real SQL database (SQLite), not a mock-up that only accepts one spelling. Type your query and run it as often as you like. Each run starts from a fresh copy of the data, so even a DELETE without WHERE does no lasting harm. It just shows you why nobody does that at work.

Check compares the result of your query with the task: columns, rows and values. What counts is the output, not whether your query matches the model answer word for word. Your query then runs again on different, hidden data, so copying a result or typing in a fixed value gets caught. When something is off, the message says what: an extra column, the wrong sort order, a missing quote or a misspelled column name.

Hints come in three steps, from the idea to an almost finished query, and the solution only appears when you ask for it. Everything runs in your browser, on a phone as well. There is no need to install MySQL or anything else.

Who the course is for

  • Complete beginners: you have never touched a database. Level 1 starts with what a table actually is.
  • Office, finance and sales roles: you want to pull lists and numbers from your CRM, ERP or accounting system yourself instead of waiting for someone to send an export.
  • Excel users: you know filters, VLOOKUP and PivotTables. In SQL the same ideas are called WHERE, JOIN and GROUP BY.
  • Job seekers: the job ad asks for SQL and you want to list it honestly and back it up in an interview.
  • Students: you need SQL for a class, a capstone project or your first internship with data.

Online SQL course or instructor-led class?

A live SQL class, in person or on a video call, has one big advantage: you can ask questions right away. But a one or two day class ends, and skills you do not use afterwards fade quickly. This course works the other way round. You learn at your own pace in short sessions of usually 10 to 20 minutes and write every query yourself. That also makes it a good warm-up before a class or a place to keep practicing after one.

Courses for your field

Once the core path is done, you can apply SQL to cases from your own line of work. Each course has six case studies and its own certificate.

  • SQL for data analysis: KPIs, funnels, ABC analysis, time series, cohorts and data quality checks.
  • SQL for finance: budget vs actual, contribution margin, accounts receivable aging, cost centers, cash flow and month-end close.
  • SQL for marketing: channels, campaigns, retention, RFM segments, basket analysis and customer lifetime value.

See all of them on the SQL intensive courses page.

Final test and certificate

The core path ends with a timed final test made of hands-on tasks, with no hints and no solutions. Just like in the exercises, every query is also checked against hidden data. Pass it and you get a LearnThisNext certificate with your name, the date and a verification link. It comes from LearnThisNext and is not an Oracle or Microsoft certification. What it shows, and which vendor exams exist, is explained on the SQL certification page.

What the course costs

Every lesson is free to read. All of level 1, including its exercises and project, is free, and from level 2 on the first exercise of each lesson is free too. Premium unlocks every other exercise, the projects from level 2 on, the final test with certificate and all exercises in the courses for your field. One Premium plan covers every subject on LearnThisNext, today Excel, SQL, VBA and Power BI. Current prices are on the pricing page.

SQL training for teams

Companies, public agencies, schools and nonprofits can buy team seats: pick the number of seats, share one join link, and everyone learns with their own account and their own progress. We do not run on-site classes with a trainer.

Frequently asked questions

Is the SQL course free?

Partly. All explanations are free, and so is the whole of level 1 with every exercise and the project. From level 2 on, the first exercise of each lesson is free and the rest is part of Premium.

How long does the course take?

A lesson usually takes 10 to 20 minutes. How fast you get through all six levels depends on how often you practice. Short, regular sessions work better than one long day.

Do I need any experience?

No. The course starts from zero. It helps if you have worked with tables before, for example in Excel, but it is not required.

Will I learn MySQL, PostgreSQL or SQL Server?

You learn SQL, the language all of them understand. The exercises run on SQLite, and what you write here works the same or almost the same in the other systems. Where they differ, the lesson says so.

Can I learn on my phone?

Yes. You can tap table and column names instead of typing them. For longer queries and the projects, a computer is more comfortable.

I already know some SQL. Do I have to start at level 1?

No. Open any lesson directly. If you solve its exercises right away, you are done in a few minutes and can move on.

Next: lesson 1

What tables, columns and primary keys are, and your first queries.

Go to SQL basics

Write to us

Choose language

Select your preferred language