SQL Quest
Sign in Français 0 XP Lvl 1

SQL courses: learn SQL step by step

20 complete lessons, from your first SELECT to window functions. Each lesson explains the syntax and how it works with a diagram, shows examples with their real results, lists the most common mistakes and offers exercises. Every query runs on the same sample database, a fictional online shop, which you can explore and query right in your browser.

The basics Beginner

1SQL SELECT: read data from a tableLearn the SQL SELECT statement: syntax, choosing columns, SELECT *, examples with their results, common mistakes and interactive exercises.2SQL AS: rename a column and compute valuesRename a column with AS, compute values (+, -, *, /) and join text with || in SQL. Examples with their results and exercises.3SQL WHERE: filter rowsFilter your data with WHERE in SQL: comparison operators, AND, OR, NOT, parentheses. Examples with their results, pitfalls and exercises.4SQL IN and BETWEEN: lists and rangesUse IN to test a list of values and BETWEEN for a range in SQL. Syntax, examples with their results, pitfalls and exercises.5SQL LIKE: search for a pattern in textSearch text with LIKE in SQL: % and _ wildcards, starts with, contains, ends with. Examples with their results, pitfalls and exercises.6SQL NULL: handling missing valuesUnderstand NULL in SQL: why = NULL does not work, IS NULL, IS NOT NULL, COALESCE / IFNULL and NULL in calculations. Examples and exercises.7SQL ORDER BY: sort the resultsSort your results with ORDER BY in SQL: ascending ASC, descending DESC, sorting on several columns and NULLs. Examples with their results.8SQL LIMIT and OFFSET: limit and paginateLimit the number of rows with LIMIT and paginate with OFFSET in SQL: top N, pagination, TOP and FETCH equivalents. Examples with their results.9SQL DISTINCT: remove duplicatesRemove duplicates with SELECT DISTINCT in SQL: on one or several columns, COUNT(DISTINCT), difference with GROUP BY. Examples and exercises.10SQL COUNT, SUM, AVG, MIN and MAXSummarize your data with SQL aggregate functions: COUNT, SUM, AVG, MIN, MAX and ROUND. Examples with their results, pitfalls and exercises.

Grouping and linking data Intermediate

Advanced queries Advanced

How to use these courses

If you are a beginner, follow the lessons in order: each notion builds on the previous ones. For every example, the “Try it in the sandbox” button opens the query in the SQL Quest editor, where you can change and run it without installing anything. Once a notion is clear, move on to the interactive exercises: your query is compared with the expected result and a tutor explains your mistakes.

The SQL taught here is standard SQL, run by SQLite. It applies to PostgreSQL, MySQL, SQL Server and Oracle; the few differences between these databases are pointed out in the lessons. The sample database keeps its French table and column names (clients = customers, produits = products, commandes = orders…): each lesson includes a glossary.