
SQL basics: from your first table to a result you can explain
A query can run successfully and answer the wrong question. I work through six orders to show how selection, grouping, missing values and result checks fit together.
Knowledge base / SQL
SQL commands and functions used in analysis: filtering, grouping, JOINs, window functions, dates and text, with notes on engine differences.
99 entries

The SQL entries describe the commands and functions that appear in typical analytical queries: filtering, grouping, JOINs, window functions, dates and text. The basics, such as SELECT, WHERE and GROUP BY, behave similarly in most databases. Date, text and JSON functions do not. The same operation in PostgreSQL, SQL Server, MySQL and SQLite often has a different name or different arguments.
For engine-specific functions, check which dialect an example targets. Before you run a query on a large table, test it on a few rows where you know the correct result. With JOINs and aggregations in particular, such a test quickly reveals duplicated rows or lost NULL values.
If you are starting out, work through “Query basics”, “Aggregations” and “JOINs and set operations” in that order. The articles below the grid show fuller examples that combine several of these elements.
No matching entries. Try a shorter name.