pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: pgsql@yukonho.de
To: pgsql-sql@postgresql.org
Subject: Re: group by function, make SQL cleaner?
Date: Thu, 16 Mar 2006 22:45:03 +0100
Message-ID: <200603162245.03701.pgsql@yukonho.de> (raw)
In-Reply-To: <4418F52F.4070804@obviously.com>
References: <4418F52F.4070804@obviously.com>

this should work, 
#
SELECT date_trunc('day',endtime),count(*)
 FROM eg_event where endtime >= '2006-02-01' and endtime < '2006-03-01'
 GROUP BY  1
  ORDER BY 1;

hope this helps 
best regards,


Stefan









Am Donnerstag, 16. März 2006 06:18 schrieb Bryce Nesbitt:
> I've got a working query:
>
> stage=# SELECT date_trunc('day',endtime),count(*)
> FROM eg_event where endtime >= '2006-02-01' and endtime < '2006-03-01'
> GROUP BY  date_trunc('day',endtime)
> ORDER BY date_trunc('day',endtime);
>
>      date_trunc      | count
> ---------------------+-------
>  2006-02-01 00:00:00 |   253
>  2006-02-02 00:00:00 |   245
>  2006-02-03 00:00:00 |   231
>  2006-02-04 00:00:00 |   313
>  2006-02-05 00:00:00 |   285
>  2006-02-06 00:00:00 |   194
>  2006-02-07 00:00:00 |   229
>  2006-02-08 00:00:00 |   239
>  2006-02-09 00:00:00 |   250
>  2006-02-10 00:00:00 |   245
>  2006-02-11 00:00:00 |   275
>
> Is there a way to eliminate the ugly repeated use of
> date_trunc('day',endtime)?
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: 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

-- 
email: stefan@yukonho.de
tel  : +49 (0)6232-497631
http://www.yukonho.de



view thread (6+ messages)  latest in thread

Message-ID: <200603162245.03701.pgsql@yukonho.de>
Permalink:  ../200603162245.03701.pgsql@yukonho.de/
Also on:    postgresql.org/message-id/200603162245.03701.pgsql@yukonho.de

 · 

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: pgsql@yukonho.de
  Subject: Re: group by function, make SQL cleaner?
  In-Reply-To: <200603162245.03701.pgsql@yukonho.de>

* 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