Re: max timestamp
От | Robert Creager |
---|---|
Тема | Re: max timestamp |
Дата | |
Msg-id | 20040215130025.4e74ebf1.Robert_Creager@LogicalChaos.org обсуждение исходный текст |
Ответ на | max timestamp (stermic@gw.co.jackson.mo.us (Michael Sterling)) |
Список | pgsql-sql |
When grilled further on (10 Feb 2004 10:14:04 -0800), stermic@gw.co.jackson.mo.us (Michael Sterling) confessed: > i'm trying to get the max time stamp, from each day, of a range of > dates, not just the max time stamp for the complete range dates but > for each day. > Well, one gross and ugly way is: SELECT MAX( "when" ) FROM readings, (SELECT DATE_TRUNC( 'day', "when" ) AS period FROM readings GROUP BY period) AS p WHERE DATE_TRUNC( 'day', "when" ) = p.period GROUP BY p.period; given the table readings looks something like: CREATE TABLE readings ( "when" TIMESTAMP DEFAULT timeofday()::timestamp NOT NULL PRIMARYKEY ); I'm curious to see other, 'better' solutions. Cheers, Rob -- 12:52:57 up 20:36, 2 users, load average: 2.08, 2.17, 2.18 Linux 2.4.21-0.13_test #60 SMP Sun Dec 7 17:00:02 MST 2003
В списке pgsql-sql по дате отправления: