Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 256F09F950B for ; Wed, 22 Aug 2007 10:35:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 82103-04 for ; Wed, 22 Aug 2007 10:35:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 1E3309F936E for ; Wed, 22 Aug 2007 10:35:19 -0300 (ADT) Received: (qmail 24064 invoked by uid 0); 22 Aug 2007 13:35:18 -0000 Received: from 195.141.84.215 by www089.gmx.net with HTTP; Wed, 22 Aug 2007 15:35:17 +0200 (CEST) Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset="us-ascii" Date: Wed, 22 Aug 2007 15:35:17 +0200 From: "Christian Kindler" Message-ID: <20070822133517.107820@gmx.net> MIME-Version: 1.0 Subject: Re: Solution to retrieve first and last row for each minute To: "roopa perumalraja" X-Authenticated: #27759442 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX1/sCK8VOLTsSMRyiVgRt3SzYNNqNzi8zead7mlg+Y rY0oIFLd7ttdExaASx9Go3bdW/GmJImjHoTA== Content-Transfer-Encoding: 7bit X-GMX-UID: rQn1cyVneWUofzry1HRzCG8xU3U4N8+U X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.013 tagged_above=0 required=5 tests=BAYES_50=0.001, FAKE_REPLY_C=2.012 X-Spam-Level: ** X-Archive-Number: 200708/195 X-Sequence-Number: 29133 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