Re: having clause question - Mailing list pgsql-general

From Ian Barwick
Subject Re: having clause question
Date
Msg-id 1d581afe041030153667a867b5@mail.gmail.com
Whole thread Raw
In response to having clause question  (Shane Wegner <shane-keyword-pgsql.a1e0d9@cm.nu>)
Responses Re: having clause question  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Sat, 30 Oct 2004 15:17:16 -0700, Shane Wegner
<shane-keyword-pgsql.a1e0d9@cm.nu> 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
barwick@gmail.com

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