From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Markus Wolters <MarkusWolters(at)gmx(dot)de> |
Cc: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Select values by interval |
Date: | 2015-11-23 16:49:06 |
Message-ID: | CAKFQuwY8U2okjoWJcVs5ft9+bzgFxbJYUHC7dVvtOEQWje=u9w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mon, Nov 23, 2015 at 9:37 AM, Markus Wolters <MarkusWolters(at)gmx(dot)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?
>
Look at:
generate_series(...)
date_part(...)
SELECT DISTINCT ON
You should consider providing a query with some test data.
WITH vals (v, ts) AS (
VALUES (1, now()), (2, now() + '2 minutes'::interval), [etc]
)
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Kretschmer | 2015-11-23 17:22:16 | Re: Select values by interval |
Previous Message | Markus Wolters | 2015-11-23 16:37:42 | Select values by interval |