Comment 8 for bug 611379

Revision history for this message
Igor Babaev (igorb-seattle) wrote :

The problem can be demonstrated even without any join:

MariaDB [test]> create table t3 (a int not null);
Query OK, 0 rows affected (0.04 sec)

MariaDB [test]> insert into t3 values (3), (1), (2);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

MariaDB [test]> select sum(distinct a) from t3 where a < 0;
+-----------------+
| sum(distinct a) |
+-----------------+
| NULL |
+-----------------+
1 row in set (0.00 sec)

MariaDB [test]> select * from (select sum(distinct a) from t3 where a < 0) as t;
+-----------------+
| sum(distinct a) |
+-----------------+
| 0 |
+-----------------+
1 row in set (0.00 sec)