SQL examples.
Talk to data.
SQL — Starter Programs
Minimal runnable programs to get you started with SQL. Admins can add more via the admin panel or the AI bulk-generate button.
SELECT Basics
SELECT *, column list, DISTINCT, AS aliases, simple WHERE, ORDER BY
Filtering & Operators
WHERE with AND/OR/NOT, IN, BETWEEN, LIKE patterns, IS NULL, comparison ops
Aggregates & GROUP BY
COUNT, SUM, AVG, MIN, MAX, GROUP BY, HAVING, multi-key grouping
JOINs
INNER, LEFT, RIGHT, FULL OUTER, CROSS, SELF join, USING vs ON
Subqueries
scalar subquery, IN-subquery, EXISTS, correlated subquery, derived table in FROM
INSERT / UPDATE / DELETE
INSERT single & multi-row, UPDATE with WHERE, DELETE with JOIN, RETURNING (PG)
DDL & Constraints
CREATE TABLE, PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, NOT NULL, DEFAULT, ALTER, DROP
Indexes & Performance
CREATE INDEX, composite index, EXPLAIN/EXPLAIN ANALYZE, ANALYZE, table stats
Indexes & Performance
CREATE INDEX, composite index, EXPLAIN/EXPLAIN ANALYZE, ANALYZE, table stats
Window Functions
ROW_NUMBER, RANK, DENSE_RANK, LAG/LEAD, SUM OVER, PARTITION BY, frame clauses
Window Functions
ROW_NUMBER, RANK, DENSE_RANK, LAG/LEAD, SUM OVER, PARTITION BY, frame clauses
Real-world Queries
monthly sales report, top-N per category, gap-and-island, running total, customer cohorts, duplicate-finder, latest-row-per-group, slowly-changing-dim, recursive org chart, anti-join missing-data
Real-world Queries
monthly sales report, top-N per category, gap-and-island, running total, customer cohorts, duplicate-finder, latest-row-per-group, slowly-changing-dim, recursive org chart, anti-join missing-data
