First mental model
Which rows must survive?
Read the picture as a guide to the rule. Venn regions describe matched and unmatched rows, not counts or one-to-many multiplication. The CROSS grid shows pairs. Check the source and result rows for the actual data.
Actual database consequence
Source rows
CLUBS
| club_id | club_name |
|---|
Source rows
EVENTS
| event_id | club_id | title | category |
|---|
Row matching
Step through result rows
Second mental model
Rows → groups → summaries
Think of 24 event cards being sorted into labeled envelopes. The aggregate is calculated inside each envelope.
Before grouping
Rows entering GROUP BY
After HAVING
Groups returned
HAVING removes complete groups, not individual source rows.
| Group | COUNT | AVG(capacity) | Visual count |
|---|
Third mental model
A smaller question feeds a larger one
Step 1
Run the inner question mentally
Step 2