Re: having clause question

Поиск
Список
Период
Сортировка
От Ian Barwick
Тема Re: having clause question
Дата
Msg-id 1d581afe041030153667a867b5@mail.gmail.com
обсуждение исходный текст
Ответ на having clause question  (Shane Wegner <shane-keyword-pgsql.a1e0d9@cm.nu>)
Ответы Re: having clause question
Список 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 по дате отправления:

Предыдущее
От: Ian Barwick
Дата:
Сообщение: Re: counting records of schema
Следующее
От: Tom Lane
Дата:
Сообщение: Re: having clause question