Re: Select values by interval
От | David G. Johnston |
---|---|
Тема | Re: Select values by interval |
Дата | |
Msg-id | CAKFQuwYwLX9SMvtni5hk7WDN4JneZhApj6ku4txfCK9Q=PwHpA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Select values by interval (Andreas Kretschmer <akretschmer@spamfence.net>) |
Ответы |
Re: Select values by interval
|
Список | pgsql-sql |
On Mon, Nov 23, 2015 at 10:22 AM, Andreas Kretschmer <akretschmer@spamfence.net> wrote:
Markus Wolters <MarkusWolters@gmx.de> wrote:
> Hi all,
>
> I have a table with value and timestamp columns. What I like to do (but am unable to find a solution) is to select the last(value) timestamp combination in every X minute interval where timestamp is between N and M. Is this possible with pgsql?
>
maybe somethink like
select *, row_number() over (partition by to_char(timestamp, 'yyyy-mm-dd
hh24:mm') order by ... desc) ...
and then pick all with row_number = 1
*untested*
Unproven but whenever you have a query of this form (row_number = 1) you should consider/test whether using DISTINCT ON with an appropriate ORDER BY clause gives you the answer faster and/or more clearly.
David J.
В списке pgsql-sql по дате отправления: