Counting distinct rows

Поиск
Список
Период
Сортировка
От John Taylor
Тема Counting distinct rows
Дата
Msg-id 02011610332501.01474@splash.hq.jtresponse.co.uk
обсуждение исходный текст
Ответы Re: Counting distinct rows  (Einar Karttunen <ekarttun@cs.helsinki.fi>)
Re: Counting distinct rows  (Steve Crawford <scrawford@pinpointresearch.com>)
Список pgsql-novice
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

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

Предыдущее
От: denis@coralindia.com
Дата:
Сообщение: select !working
Следующее
От: Einar Karttunen
Дата:
Сообщение: Re: Counting distinct rows