Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Not a Bug
-
None
-
None
Description
Hi,
I wonder if it's a bug or a feature, but I find this behaviour quite disturbing.
If there's no join and if AVG() is used without GROUP BY and with a WHERE clause on a non matching row, it still returns a result.
e.g. :
MariaDB [(none)]> SELECT AVG(a), b FROM (SELECT 1 as a, 1 as b) a WHERE b=10;
|
+--------+---+
|
| AVG(a) | b |
|
+--------+---+
|
| NULL | NULL |
|
+--------+---+
|
However, if a GROUP BY is added, no rows are returned :
SELECT AVG(a), b FROM (SELECT 1 as a, 1 as b) a WHERE b=10 GROUP BY a;
|
Empty set (0.00 sec)
Thanks and regards,
Jocelyn Fournier