Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain NULLs when teaching count #324

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions _episodes/06-agg.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,16 @@ SELECT sum(reading) FROM Survey WHERE quant = 'sal';
|64.83 |

We used `count(reading)` here,
but we could just as easily have counted `quant`
or any other field in the table,
or even used `count(*)`,
but could have used `count(*)`,
since the function doesn't care about the values themselves,
just how many values there are.
just how many rows there are.
Even a column other than `reading` could be used,
but note that any `NULL` value will not be counted
(to see, try `count`ing the `person` column, which contains a
row with a `NULL`).
This perhaps non-obvious behavior
of aggregation functions is covered later
in this episode.

SQL lets us do several aggregations at once.
We can,
Expand Down