Re: having clause question - Mailing list pgsql-general

From Ian Barwick
Subject Re: having clause question
Date
Msg-id [email protected]
Whole thread Raw
In response to having clause question  (Shane Wegner <[email protected]>)
Responses Re: having clause question
List pgsql-general
On Sat, 30 Oct 2004 15:17:16 -0700, Shane Wegner
<[email protected]> wrote:
> Hello,
(...)
> I want to retrieve any last names with more than 1
> occurence in the table.  Under MySQL, this query does the
> trick.
> select lastname,count(*) as c from names group by lastname
> having c > 1;
>
> But under PG, it errors out
> ERROR:  column "c" does not exist
>
> Is it possible to do a query like this with PostgreSQL?

select lastname,count(*) as c from names group by lastname having count(*) > 1;

HTH

Ian Barwick
[email protected]

pgsql-general by date:

Previous
From: Ian Barwick
Date:
Subject: Re: counting records of schema
Next
From: Tom Lane
Date:
Subject: Re: having clause question