Subject | Re: having count(*) not in (select ===> EVL_expt |
---|---|
Author | Svein Erling Tysvær |
Post date | 2006-02-24T09:13:15Z |
Hi again Alexandre!
--- In firebird-support@yahoogroups.com, "amoradell" wrote:
> With the following query, I get also the error
>
> select e.dept_no, count(*)
> from EMPLOYEE e
> group by e.dept_no
> having count(*) not in (select j.job_grade
> from job j)
I agree with you that this query ought to work and that it is a
serious bug. I tried to run
//WARNING: This select will destroy your database!!!
select r.rdb$relation_id, count(*)
from rdb$database r
group by r.rdb$relation_id
having count(*) not in (select r2.rdb$relation_id from rdb$database)
//WARNING: This select will destroy your database!!!
and it came to a screaming halt! I didn't find anything about it in
the Firebird 1.5.3 release notes (I use 1.5.2) or the bug tracker, so
I wrote a bug report on SourceForge. In my opinion, no SELECT should
ever destroy the database, so I think it is a serious error.
> in fact in having clause, you can put every aggregate function even
> if it's not in the select clause, the only constraint is the
> existence of the field, example :
>
> select e.dept_no, count(*) from employee e
> group by e.dept_no
> having max(e.emp_no)<>min(e.emp_no)
>
> you find dept_no with several employee
Well, it proves that my thoughts about the having clause was wrong,
even though I'd write a query as the one above this way:
select e.dept_no, count(*) from employee e
where exists(select * from employee e2 where e2.dept_no = e.dept_no
and e2.emp_no <> e.emp_no)
group by e.dept_no
Set