Re: Solution to retrieve first and last row for each minute

From: "Christian Kindler" <christian(dot)kindler(at)gmx(dot)net>
To: "roopa perumalraja" <roopabenzer(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Solution to retrieve first and last row for each minute
Date: 2007-08-22 13:35:17
Message-ID: 20070822133517.107820@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Its really slow but what you can do is something like the following:

select count(a.*), b.* from foo.bar a,
(
select price from foo.bar order by time asc limit 1
union
select price from foo.bar order by time desc limit 1
) as b
group by b.price

... just do the "wheres" as you need ...

Chris

PS its untested maybe there are some syntax miss-spells

--
cu
Chris

Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2007-08-22 14:10:44 Re: Partial index and query plan
Previous Message Aleksandr Vinokurov 2007-08-22 12:57:42 Partial index and query plan