SQL GROUP BY 子句如何管理 NULL 值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22802078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:32:13  来源:igfitidea点击:

How does the GROUP BY clause manage the NULL values?

sqlsql-server

提问by Nizam Uddin Sikder

How does the GROUP BY clause manage the NULL values? Does it correspond to the general treatment of these values?

GROUP BY 子句如何管理 NULL 值?它是否符合对这些值的一般处理?

回答by Mudassir Hasan

Null values of a column are grouped as a separate group.

列的空值被分组为一个单独的组。

See SQL Fiddledemonstrating Group By and aggregate functions on nullable column

请参阅SQL Fiddle演示可空列上的 Group By 和聚合函数

回答by Euro Micelli

You mean, when you GROUP BYa nullable column? All rows with a NULL in the column are treated as if NULL was another value.

你的意思是,当你GROUP BY是一个可以为空的列时?列中具有 NULL 的所有行都被视为 NULL 是另一个值。

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

http://technet.microsoft.com/en-us/library/ms177673.aspx

回答by yugesh

Group By groups all the records with NULL values.

Group By 将所有具有 NULL 值的记录分组。