Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 6A2112E35D2 for ; Thu, 13 Dec 2007 05:47:51 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 03765-05 for ; Thu, 13 Dec 2007 05:47:38 -0400 (AST) Received: from web94315.mail.in2.yahoo.com (web94315.mail.in2.yahoo.com [203.104.16.225]) by postgresql.org (Postfix) with SMTP id 1D1812E375F for ; Thu, 13 Dec 2007 05:47:39 -0400 (AST) Received: (qmail 77094 invoked by uid 60001); 13 Dec 2007 09:47:36 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=NDj1WxQzBGaavvjYpQv9AyJLrJa0oICdtNA4aVFjkPoQKy+m9A+K7jqScVIjJX2Mww2Uf5mZOPP1zXccm0bJnjShLQtu1lfajQTV8ET26ac56XvSRNUOzvcRYOv1plwsgEGGaRvo55knYehUVXRVeehvPwgda1tF8H8sX3bmmEM=; X-YMail-OSG: DuZrVxQVM1kgZJPeNakT1pWjnKc35i73zpR9l_mBlXXr9BHFBg292QNVuHkF2UZzZg-- Received: from [59.163.11.66] by web94315.mail.in2.yahoo.com via HTTP; Thu, 13 Dec 2007 09:47:36 GMT Date: Thu, 13 Dec 2007 09:47:36 +0000 (GMT) From: Ashish Karalkar Subject: SQL Query To: pgsql-novice@postgresql.org, ashish.karalkar@netcore.co.in MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1680587559-1197539256=:76564" Content-Transfer-Encoding: 8bit Message-ID: <591590.76564.qm@web94315.mail.in2.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/885 X-Sequence-Number: 125628 --0-1680587559-1197539256=:76564 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello List member, I have a table which ha sfollowing structure my_table: ( output_id serial priimary key, parent_id int, output_date timesatmp ) parent_table: (parent_id int, parent desc ) the my_table contains data for previous as well as future output dates. for single parent there may be multiple rows. I want to retrieve all the output_id which are having latest output_date but less than now() (no future output_dates) group by parent_id Thanks in advance With Regards Ashish... --------------------------------- Chat on a cool, new interface. No download required. Click here. --0-1680587559-1197539256=:76564 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello List member,
I have a table which ha sfollowing structure

my_table:
(
    output_id serial priimary key,
    parent_id int,
    output_date timesatmp
)

parent_table:

(parent_id int,
parent desc
)

the my_table contains data for previous as well as future output dates.
for single parent there may be multiple rows.

I want to retrieve all the output_id  which are having latest output_date but less than now() (no future output_dates) group by  parent_id

Thanks in advance

With Regards
Ashish...













Chat on a cool, new interface. No download required. Click here. --0-1680587559-1197539256=:76564--