agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: Select values by interval
Date: Mon, 23 Nov 2015 18:22:16 +0100
Message-ID: <20151123172216.GA5760@tux> (raw)
In-Reply-To: <trinity-9d150dc2-4428-4d05-a7a8-9ab52fcef606-1448296662813@3capp-gmx-bs03>
References: <trinity-9d150dc2-4428-4d05-a7a8-9ab52fcef606-1448296662813@3capp-gmx-bs03>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

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* 


Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (5+ messages)  latest in thread

Message-ID: <20151123172216.GA5760@tux>
Permalink:  ../20151123172216.GA5760@tux/
Also on:    postgresql.org/message-id/20151123172216.GA5760@tux

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: akretschmer@spamfence.net
  Subject: Re: Select values by interval
  In-Reply-To: <20151123172216.GA5760@tux>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox