I have a user-defined function udf
that returns a boolean, in MariaDB 5.5.
The following gives me what I expect:
select c, count(*)
from (
select fld, count(*)c
from tbl
where udf(fld)
group by fld
) t
group by c;
+---+----------+
| c | count(*) |
+---+----------+
| 1 | 12345 |
| 2 | 1234 |
| 3 | 123 |
| 4 | 12 |
| 5 | 1 |
+---+----------+
5 rows in set (26.75 sec)
Likewise, the following gives me the number 12345
(from the table just above), just as I expect:
select anotherfield, count(*)
from tbl
where udf(fld)
and fld in (
select fld from (
select fld,count(*)c
from tbl
group by fld
having c=1
)t
)
group by anotherfield with rollup;
I would expect that the following would also give me 12345
:
select anotherfield, count(*)
from tbl
where udf(fld)
and fld not in (
select fld from (
select fld,count(*)c
from tbl
group by fld
having c>1
)t
)
group by anotherfield with rollup;
However, it gives me no rows. Why?