pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rodrigo De León <rdeleonp@gmail.com>
To: pgsql-sql@postgresql.org, "Edward W. Rouse" <erouse@comsquared.com>
Subject: Re: group by day
Date: Thu, 24 May 2007 14:45:47 -0500
Message-ID: <a55915760705241245q521967e1rfc46d7639ebb8bc2@mail.gmail.com> (raw)
In-Reply-To: <04c201c79e34$4e3877c0$143c520a@ntc2s.comsquared.com>
References: <04c201c79e34$4e3877c0$143c520a@ntc2s.comsquared.com>

On 5/24/07, Edward W. Rouse <erouse@comsquared.com> 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



view thread (4+ messages)  latest in thread

Message-ID: <a55915760705241245q521967e1rfc46d7639ebb8bc2@mail.gmail.com>
Permalink:  ../a55915760705241245q521967e1rfc46d7639ebb8bc2@mail.gmail.com/
Also on:    postgresql.org/message-id/a55915760705241245q521967e1rfc46d7639ebb8bc2@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rdeleonp@gmail.com, erouse@comsquared.com
  Subject: Re: group by day
  In-Reply-To: <a55915760705241245q521967e1rfc46d7639ebb8bc2@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox