Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2.3
-
None
Description
Let 's have a table like this one:
CREATE TABLE t1 (a INT, b VARCHAR(8));
|
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
|
The following works fine:
|
MariaDB [test]> select max(a), row_number() over () from t1 where a > 2;
|
+--------+----------------------+
|
| max(a) | row_number() over () |
|
+--------+----------------------+
|
| NULL | 1 |
|
+--------+----------------------+
|
|
MariaDB [test]> select max(a), sum(max(a)) over () from t1 where a > 2;
|
+--------+---------------------+
|
| max(a) | sum(max(a)) over () |
|
+--------+---------------------+
|
| NULL | NULL |
|
+--------+---------------------+
|
|
MariaDB [test]> select max(a), sum(max(a)) over (partition by max(a)) from t1 where a > 2;
|
+--------+----------------------------------------+
|
| max(a) | sum(max(a)) over (partition by max(a)) |
|
+--------+----------------------------------------+
|
| NULL | NULL |
|
+--------+----------------------------------------+
|
Yet these queries return wrong results:
MariaDB [test]> select max(a), row_number() over () from t1 where 1 = 2;
|
+--------+----------------------+
|
| max(a) | row_number() over () |
|
+--------+----------------------+
|
| NULL | 0 |
|
+--------+----------------------+
|
|
MariaDB [test]> select max(a), sum(max(a)) over () from t1 where 1 = 2;
|
+--------+---------------------+
|
| max(a) | sum(max(a)) over () |
|
+--------+---------------------+
|
| NULL | |
|
+--------+---------------------+
|
|
MariaDB [test]> select max(a), sum(max(a)) over (partition by max(a)) from t1 where 1 = 2;
|
+--------+----------------------------------------+
|
| max(a) | sum(max(a)) over (partition by max(a)) |
|
+--------+----------------------------------------+
|
| NULL | |
|
+--------+----------------------------------------+
|