Re: Counting distinct rows

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Re: Counting distinct rows
Дата
Msg-id 20020116171033.5CB7410444@polaris.pinpointresearch.com
обсуждение исходный текст
Ответ на Counting distinct rows  (John Taylor <postgres@jtresponse.co.uk>)
Список pgsql-novice
Try:

select id, count(*) from basketupdates group by id order by id desc;


On Wednesday 16 January 2002 02:38, John Taylor wrote:
> Hi,
>
> I'm having problems counting the number of distinct rows in a table.
>
> I've tried the following:
>
>     select distinct on(id) count(id)  from basketupdates order by id desc;
>
> but I get the error
>
>     ERROR:  Attribute basketupdates.id must be GROUPed or used in an aggregate
> function
>
> I think it should say "MUST NOT", as if I remove the aggregate it works
> fine. So I don't think this is the way to go about it.
>
> Can anyone tell how I should be going about counting the distinct ids in a
> table ?
>
>
> Thanks
> JohnT
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Jules Alberts"
Дата:
Сообщение: Vim syntaxfile
Следующее
От: denis@coralindia.com
Дата:
Сообщение: Re: select !working