From the course: Advanced SQL: Logical Query Processing, Part 1

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Dealing with NULLs and elimination duplicates

Dealing with NULLs and elimination duplicates - SQL Tutorial

From the course: Advanced SQL: Logical Query Processing, Part 1

Start my 1-month free trial

Dealing with NULLs and elimination duplicates

- [Instructor] Grouping of nullable expressions treats all nulls as a single group. And if you find this confusing you're in very good company. Just in the previous chapter I told you that one null is never equal to another null. So how come they are treated in a single group? Well, it wouldn't be very useful to create a group for each row with a null. Therefore grouping is based on values that are distinct from each other, not ones that are mathematically equal. Remember that even though nulls are not equal a null is not distinct from another. With a few exceptions aggregate functions ignore nulls altogether. And this makes sense as the aggregate can only rely on known values when reporting max, min, sum, and even count of an explicit expression. Count star is a special aggregate function that counts the number of rows per group. It doesn't reference or cares about any specific expression value. Therefore nulls are…

Contents