Cheatsheets
The condensed version of the reference: dense tables and one-line patterns you can scan in seconds. Examples use DuckDB SQL against the Garden Shop dataset, with notes where other databases differ.
Cheatsheets are for moments when you remember the concept but not the exact syntax. Keep them open while writing a query, reviewing a result, or translating a pattern from another SQL dialect.
Start with query basics for SELECT, WHERE, ORDER BY, and LIMIT. Use the joins sheet when combining tables, aggregates when building summaries, and functions when cleaning text or working with dates.
Each sheet favors copyable patterns over long explanation. If a query is failing or the result looks wrong, jump from the cheatsheet into the related reference page or mistake guide for the reason behind the pattern.
The examples are intentionally small enough to adapt: swap in your table names, keep the clause order, and run the query before adding the next condition or join.
SELECT, WHERE, ORDER BY, and LIMIT at a glance.
INNER, LEFT, RIGHT, FULL, and CROSS, with what each one keeps.
COUNT, SUM, AVG, GROUP BY, and HAVING.
The everyday date and text functions, with dialect notes.
OVER, PARTITION BY, ranking, LAG/LEAD, and running totals.
Scalar, IN, and EXISTS subqueries plus the WITH clause.
UNION, UNION ALL, INTERSECT, and EXCEPT side by side.
Searched and simple CASE, plus conditional aggregation.
IS NULL, COALESCE, NULLIF, and null-safe equality.
Want the longer explanations? See the Reference section, or practice the patterns in the hands-on SQL lessons.
If you are not sure which syntax you need, begin with query basics, then move to joins or aggregates once the result needs columns from multiple tables or one row per group.