Re: group by function, make SQL cleaner?
От | Stefan Becker |
---|---|
Тема | Re: group by function, make SQL cleaner? |
Дата | |
Msg-id | 200603160746.27272.stefan@yukonho.de обсуждение исходный текст |
Ответ на | group by function, make SQL cleaner? (Bryce Nesbitt <bryce1@obviously.com>) |
Список | pgsql-sql |
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; 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
В списке pgsql-sql по дате отправления: