Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id A302B2E3DC0 for ; Thu, 13 Dec 2007 09:02:59 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 77396-06 for ; Thu, 13 Dec 2007 09:02:51 -0400 (AST) Received: from barracuda.intoto.com (ip-66-80-10-146.dsl.sca.megapath.net [66.80.10.146]) by postgresql.org (Postfix) with ESMTP id 23B222E3DB0 for ; Thu, 13 Dec 2007 09:02:56 -0400 (AST) Received: from angel.intoto.com (smtp.intoto.com [10.1.5.29]) by barracuda.intoto.com (Spam Firewall) with ESMTP id 0D61231EE2; Thu, 13 Dec 2007 05:02:49 -0800 (PST) Received: from brahma.hyd.intoto.com (intotoind.com [172.16.1.10]) by angel.intoto.com (8.13.1/8.13.1) with ESMTP id lBDE9rDH012074; Thu, 13 Dec 2007 06:09:54 -0800 Received: from 1mc110.intotoind.com (1mc110.hyd.intoto.com [172.16.1.110]) by brahma.hyd.intoto.com (8.13.1/8.13.1) with ESMTP id lBDD2iLG030962; Thu, 13 Dec 2007 18:32:45 +0530 Date: Thu, 13 Dec 2007 13:02:44 +0000 From: Trinath Somanchi To: Ashish Karalkar Cc: pggeneral Subject: Re: SQL Query X-Virus-Scanned: by Intoto Anti-X 1.0; Thu, 13 Dec 2007 18:32:08 +0530 X-Spam-Scanned: by Intoto Anti-X 1.0; Thu, 13 Dec 2007 18:32:08 +0530 X-Virus-Scanned: by Intoto Anti-X 1.0; Thu, 13 Dec 2007 18:32:06 +0530 X-Spam-Scanned: by Intoto Anti-X 1.0; Thu, 13 Dec 2007 18:32:06 +0530 Message-ID: <20071213130244.090cb587@1mc110.intotoind.com> In-Reply-To: <401674.75312.qm@web94303.mail.in2.yahoo.com> References: <401674.75312.qm@web94303.mail.in2.yahoo.com> Reply-To: trinaths@intoto.com Organization: Intoto Software (I) Pvt Ltd X-Mailer: Claws Mail 3.1.0 (GTK+ 2.10.4; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.62 on 172.16.1.10 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/893 X-Sequence-Number: 125636 Hi , Try this out SELECT count(o.id) FROM output_table o , parent_table p WHERE o.pid=p.pid AND o_date < now() GROUP BY p.pid ; On Thu, 13 Dec 2007 10:00:56 +0000 (GMT) Ashish Karalkar wrote: > 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... > > > --------------------------------- > Forgot the famous last words? Access your message archive online. > Click here. -- Trinath Somanchi , (trinaths@intoto.com), ******************************************************************************** This email message (including any attachments) is for the sole use of the intended recipient(s) and may contain confidential, proprietary and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please immediately notify the sender by reply email and destroy all copies of the original message. Thank you. Intoto Inc.