Re: Select values by interval - Mailing list pgsql-sql

From David G. Johnston
Subject Re: Select values by interval
Date
Msg-id CAKFQuwY8U2okjoWJcVs5ft9+bzgFxbJYUHC7dVvtOEQWje=u9w@mail.gmail.com
Whole thread Raw
In response to Select values by interval  ("Markus Wolters" <MarkusWolters@gmx.de>)
List pgsql-sql
On Mon, Nov 23, 2015 at 9:37 AM, 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?

​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.

pgsql-sql by date:

Previous
From: "Markus Wolters"
Date:
Subject: Select values by interval
Next
From: Andreas Kretschmer
Date:
Subject: Re: Select values by interval