Cheat Sheet
DATABASECHEAT SHEETS
SHEET 06
Counting, Grouping and Subqueries
M.R. Sterling
Database Intro · Sheet 06

Counting, Grouping and SubqueriesSQLite

GROUP BY drawn as buckets of real rows, then the five aggregate functions, COUNT(*) against COUNT(column), HAVING, and LEFT JOIN for the zero groups. Then every kind of subquery, and the NULL that empties NOT IN.

Or get all 6 in the Database Cheat Sheets: Intro Pack for $19, or with the whole Health Database Clinic series in the Health Database Clinic - Complete + Cheat Sheets for $99.

Instant PDF downloadsent the moment you pay
Two A4 pagesprint front and back
SQLiteevery query runs as printed
Keep it foreverno expiry, no account

What the sheet looks like

A blurred preview, to show the layout and how much fits on the two pages. The full, print-sharp sheet comes with your download.

Page 1 of the Counting, Grouping and Subqueries cheat sheet
Page 1 (front)
Page 2 of the Counting, Grouping and Subqueries cheat sheet
Page 2 (back)

What is on this sheet

GROUP BY as buckets
The five aggregates
COUNT(*), COUNT(column), COUNT(DISTINCT)
Keep the zero groups
HAVING and WHERE
Scalar and IN subqueries
NOT IN and the NULL trap
Correlated, EXISTS and derived tables
Common mistakes
Learn it properly

The books this sheet pairs with

The sheet reminds you. These books teach it, one idea at a time, with every example worked.

More Database Intro sheets

One email when a new book lands

No schedule, no filler. Just the new titles and the odd free chapter.