SQL Lab
Practice SQL in the browser. No setup, no credentials, no timeouts.
Core SQL
7 packsSELECT, filtering, and sorting
SELECT chooses output columns. WHERE chooses rows.
JOINs, LEFT JOIN, and missing rows
INNER JOIN returns only rows that have a match in both tables.
CASE, NULL, and clean output
NULL means missing or unknown, not an empty string or zero.
Date and text functions
Date functions let you bucket and filter time-based records.
Aggregation, GROUP BY, and HAVING
GROUP BY collapses rows into groups based on one or more columns.
Set operations and self joins
UNION combines compatible result sets and removes duplicates.
Subqueries and CTEs
A subquery in SELECT or WHERE that returns exactly one row and one column is a scalar subquery.
Query Crafting
6 packsWindow functions
Window functions compute values across related rows while keeping row detail.
Recursive CTEs and hierarchies
A recursive CTE has an anchor query and a recursive query.
Query shaping and duplicate control
Joining multiple one-to-many tables can multiply rows.
CTEs and Subqueries Deep
A subquery is a query nested inside another query. It can appear in SELECT, FROM, WHERE, or HAVING.
Mixed L2: Reporting drills
Start by identifying the tables you need and how they relate.
Window Functions Deep
GROUP BY collapses rows into groups. Window functions keep every row and compute a value across a related set.
PostgreSQL Specific
10 packsPostgreSQL JSONPath
JSONPath is a query language for JSONB built into PostgreSQL 12+.
PostgreSQL JSONB
JSONB is common for event payloads, settings, and semi-structured metadata.
PostgreSQL full-text search
PostgreSQL full-text search can cover many product-search and admin-search needs before adding a separate search system.
PostgreSQL functions
Functions let you encapsulate logic inside the database.
PostgreSQL types
PostgreSQL supports arrays as first-class column types.
PostgreSQL Views
Create, manage, and optimize views including materialized views, updatable views, and view dependencies.
PostgreSQL Full-Text Search
Build and query full-text search indexes using tsvector, tsquery, and ranking functions.
PostgreSQL Sequences & ID Generation
Master SERIAL, IDENTITY, UUID, and custom sequence patterns for robust ID generation.
PostgreSQL LATERAL Joins
Use LATERAL to correlate subqueries and build powerful row-by-row computations.
PostgreSQL idioms
PostgreSQL has useful query forms beyond the smallest shared SQL core.
Backend / Production
14 packsPostgreSQL EXPLAIN basics
EXPLAIN is how PostgreSQL shows the plan it picked for a query.
PostgreSQL constraints and integrity
Application validation is useful, but database constraints protect every write path.
PostgreSQL row-level security
Row-level security moves some authorization rules into PostgreSQL itself.
PostgreSQL app writes
Application SQL is not only SELECT: write paths need predictable conflict handling and returned state.
PostgreSQL indexes
Indexes are part of query design, not an afterthought.
PostgreSQL reporting tables
High-read dashboards often need precomputed query shapes.
PostgreSQL partitioning
Partitioning is a physical design tool for very large tables and retention-heavy workloads.
PostgreSQL triggers
Triggers run code automatically when rows change.
PostgreSQL upsert and transactions
RETURNING lets you get the inserted or updated row without a second query.
PostgreSQL production query patterns
Production SQL is often about making the database do less work predictably.
PostgreSQL queues and locks
Small and medium systems often use PostgreSQL as the first durable job queue.
PostgreSQL migrations and backup/restore
Production migrations should avoid invalid intermediate states: add nullable columns first, backfill data, then add defaults and NOT NULL constraints.
PostgreSQL transactions and race conditions
A race condition appears when two workers read the same old state and both try to write a new state.
PostgreSQL Administration & Operations
Essential DBA operations: user management, backups, replication basics, and monitoring queries.
Schema & Design
2 packsSchema Design Mini
Schema design is the foundation of reliable data. Choose types that match your domain and constraints that prevent invalid states.
Schema-to-production mini project
This pack connects the separate skills: schema design, seed data, reporting queries, indexes, migration, and restore verification.