Re: SQL count question
Posted in 1997
Sean O'Hare — — source: Informix-list mailing list archive (1991-1998)
Matt Brickley wrote:
>
> On SE 5.01, SCO Unix 3.2v4.2
> I am trying to use the aggregate count(*) to select rows where
> there are more than on occurrance.
>
> The Informix guide to SQL on pg 7-377 shows this statement:
>
> select fname,count(*) from customer
> group by fname
> where count(*) > 1>
> This format gave me a syntax error
>
> When I put the where before the group by like this:
>
> select fname,count(*) from customer
> where count(*) > 1
> group by fname>
> I get a 595 - Bad use of aggregate in this context
>
> How do I do it?
Hi
When using aggregate functions as criteria us the having clause instead
of the where clause
select fname,count(*) from customer
group by fname
having count(*) > 1
HTH
Cheers
Sean