Subject having count(*) not in (select ===> EVL_expt
Author amoradell
Hello,

The following query is not supported by Firebird 1.5.x :
"having" and "not in (select..." are not compatible
but "having" and "in (select..." is ok

select e.dept_no, count(e.emp_no)
from EMPLOYEE e
group by e.dept_no
having count(e.emp_no) not in (select j.job_grade
from job j)

In firebird.log after execution

AMC1 (Server) Tue Feb 21 21:00:18 2006
Database: C:\FB153\EXAMPLES\EMPLOYEE.FDB
internal gds software consistency check (EVL_expt: invalid
operation (232))

I have to disconnect from the database (every client must also
disconnect)
and reconnect

The solution :

select e.dept_no, count(e.emp_no)
from EMPLOYEE e
group by e.dept_no
having not exists (select j.job_grade
from job j
where j.job_grade=count(e.emp_no))

In Firebird 2.0 beta 2, it works fine.

Regards

Alexandre Moradell