Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 为什么聚合函数至少返回一行_Mysql_Aggregate Functions - Fatal编程技术网

Mysql 为什么聚合函数至少返回一行

Mysql 为什么聚合函数至少返回一行,mysql,aggregate-functions,Mysql,Aggregate Functions,查询从dual where false中选择1返回0行,但查询从dual where false中选择max(1)返回一行内容为空 这背后的原因是什么?带有where 1=0子句的查询会过滤掉所有行,并返回一个空集 在整个表上没有分组的聚合。如果表中不包含行,则最大值将为null,但它仍会计算聚合。如果将group by添加到查询中,则不会返回任何内容

查询
从dual where false中选择1
返回0行,但查询
从dual where false中选择max(1)返回一行内容为空


这背后的原因是什么?

带有
where 1=0
子句的查询会过滤掉所有行,并返回一个空集


在整个表上没有分组的聚合。如果表中不包含行,则最大值将为
null
,但它仍会计算聚合。

如果将group by添加到查询中,则不会返回任何内容