Re: Group by 15 Minute Steps

Поиск
Список
Период
Сортировка
От Jonathan Daugherty
Тема Re: Group by 15 Minute Steps
Дата
Msg-id 20050321043010.GC20336@vulcan.cprogrammer.org
обсуждение исходный текст
Ответ на Group by 15 Minute Steps  (Martin Knipper <martin@mk-os.de>)
Список pgsql-sql
# Usally, the steps between each entries is 300 seconds.  How can I
# group by by 15, 30, 45 minutes so that i can get averages over the
# specified timeframe?

For 15-minute data, I'd compute the "quadrant" of each record and
group by the quadrant number.  Anything that occurs from :00 to :14 is
in quadrant zero, :15 - :29 is quadrant 1, etc., yielding quadrants
0-3.

mydb> SELECT (time / (15 * 60)) AS quadrant, SUM(ifinoctets) FROM
mytable GROUP BY quadrant ORDER BY quadrant;

Divide the time by 60 to get minutes and 15 to get quadrants.  You can
see how to extend this for other intervals.

--  Jonathan Daugherty Command Prompt, Inc. - http://www.commandprompt.com/ PostgreSQL Replication & Support Services,
(503)667-4564
 



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Hermann Draeger"
Дата:
Сообщение: tablename as function parameter
Следующее
От: "mroyce@gmail.com"
Дата:
Сообщение: timestamp precision - can I control precision at select time or set for all time?