How does the GROUP BY clause manage the NULL values? Does it correspond to the general treatment of these values?
We can see that the first result value is a NULL represented by an empty string (the empty line before the IT department). This empty space represents all the NULL values returned by the GROUP BY clause, so we can conclude that GROUP BY treats NULLs as valid values.
The GROUP BY clause instructs the DBMS to group the data and then perform the aggregate (function) on each group rather than on the entire result set. Aside from the aggregate calculation statements, every column in your SELECT statement must be present in the GROUP BY clause.
How are NULLs treated if they exist in grouping attributes? They are separated into a group created for all tuples with a NULL value in grouping attribute. A query (SELECT statement) inside a query that can appear as part of a condition in the WHERE or HAVING clauses as well as in the FROM clause.
Null values of a column are grouped as a separate group.
See SQL Fiddle demonstrating Group By and aggregate functions on nullable column
You mean, when you GROUP BY
a nullable column? All rows with a NULL in the column are treated as if NULL was another value.
If a grouping column contains null values, all null values are considered equal, and they are put into a single group.
http://technet.microsoft.com/en-us/library/ms177673.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With