SQL practice › SQL reference

SQL reference, with queries you can run

Each page explains one piece of SQL the way it comes up at work and in interviews: what it does, the mistakes that give wrong rows without any error, and the questions people ask about it. Every query on a page runs on a real database in your browser, so you can change it and see what comes back, then solve a few exercises. Answers are included.

Joins

Grouping

Filtering and expressions

Window functions

Subqueries, CTEs and UNION

Classic interview queries

More SQL practice

SQL practice onlineSQL skills testSQL errors, with a query to fixSQL interview questions, with answers