| От | Richard Huxton |
|---|---|
| Тема | Re: Filtering data based on timestamp |
| Дата | |
| Msg-id | 43E8C18B.1010206@archonet.com обсуждение исходный текст |
| Ответ на | Filtering data based on timestamp (Panos Kassianidis <pkas@inaccessnetworks.com>) |
| Список | pgsql-sql |
Panos Kassianidis wrote:
> and I would like to retrieve values recorded in the last 2 hours but
> with an interval of 5 minutes, which means that my query should return
> one tuple for every 5 tuples in the table and the value of this tuple
> should be an average of 5 values.
> Does anyone have any clue how I can make this query? I have though
> about somehow grouping the tuples with group by and use the AVG
> function but the tuples don't have anything in common to be grouped by.
You'll need to write an enhanced version of date_trunc() that can group
timestamps into arbitrary units, e.g. my_date_trunc('... 12:34', 'm', 5) = '...12:30'
Then you can group by your new value.
-- Richard Huxton Archonet Ltd
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера