Subject Re: [firebird-support] conditional on count
Author Helen Borrie
At 09:30 AM 11/02/2007, you wrote:
>FB 1.5
>
>I would like to run the following SQL:
>
> select CustomPlan_ID, count(*) as ItemCount
> from CustomPlanInfo
> where ItemCount > 1 <<-- doesn't work
>group by 1
>
>But it doesn't like ItemCount. Is there a way to do this?

Yup. WHERE applies to searches, i.e. rows in the tables, whilst
HAVING applies to the result of a grouping. So:

select CustomPlan_ID, count(*) as ItemCount
from CustomPlanInfo
group by 1
HAVING count(*) > 1

./heLen