Learn SQL online in a real database client

These lessons run in a database client with a shop database containing 23 tables and roughly 50,000 rows. The sample is the same one included with Planche, so you can work with realistic joins and grouped results.

Most examples include a Run in Planche button. It opens the app with the sample database and query ready in a tab. No account or installation is required, and the database stays in your browser.

Core path

  1. What a database looks like Tables, rows, columns, NULL, primary keys, running a query
  2. Reading rows: SELECT, WHERE, ORDER BY, LIMIT SELECT, choosing columns, WHERE, ORDER BY, LIMIT, column aliases
  3. Filtering rows: WHERE in full AND / OR precedence, IN, BETWEEN, LIKE, IS NULL
  4. Combining tables: JOIN INNER JOIN, multi-table joins, LEFT JOIN, ON versus WHERE, self-joins
  5. Summarizing rows: GROUP BY COUNT, SUM, AVG, MIN, MAX, GROUP BY, HAVING, COUNT DISTINCT
  6. Queries inside queries: subqueries Scalar subqueries, IN, EXISTS, NOT EXISTS, derived tables, correlated subqueries
  7. Multi-step queries and calculations across rows: CTEs and window functions WITH, chained CTEs, ROW_NUMBER, RANK, DENSE_RANK, SUM OVER, LAG
  8. Changing data: INSERT, UPDATE, DELETE INSERT, UPDATE, DELETE, primary key conflicts, BEGIN / COMMIT / ROLLBACK
  9. Why is this slow? Indexes and EXPLAIN EXPLAIN QUERY PLAN, table scans, index searches, sargable conditions

By dialect