Re: group by day

Поиск
Список
Период
Сортировка
Искать
От
Rodrigo De León
Тема
Re: group by day
Дата
в 16:46:13
Msg-id
a55915760705241245q521967e1rfc46d7639ebb8bc2@mail.gmail.com
Ответ на
group by day (Edward W. Rouse)
Список
Дерево обсуждения
group by day "Edward W. Rouse" <erouse@comsquared.com>
Re: group by day "A. Kretschmer" <andreas.kretschmer@schollglas.com>
Re: group by day Richard Huxton <dev@archonet.com>
Re: group by day "Rodrigo De León" <rdeleonp@gmail.com>
On 5/24/07, Edward W. Rouse  wrote:
>
>
> I have an audit table that I am trying to get a count of the number of
> distinct entries per day by the external table key field. I can do a
>
> select count(distinct(id)) from audit where timestamp >= '01-may-2007'
>
> and get a total count. What I need is a way to group on each day and get a
> count per day such that the result would be something like
>
> date                    count
> 01-may-2007        107
> 02-may-2007        215
> 03-may-2007        96
> 04-may-2007        0
>
>
> I would prefer the 0 entries be included but can live without them. Thanks.
>
> Oh, postgres 7.4 by the way.
>
>
>
> Edward W. Rouse
>
> ComSquared Systems, Inc.
>
> 770-734-5301

SELECT   TIMESTAMP, COUNT(DISTINCT(ID))   FROM AUDIT
GROUP BY TIMESTAMP
ORDER BY TIMESTAMP

В списке pgsql-sql по дате отправления
От: A. Kretschmer
Дата:
Сообщение: Re: group by day
От: Richard Huxton
Дата:
Сообщение: Re: group by day
FAQ