X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 64EA15331D for ; Fri, 6 May 2005 05:40:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69056-01 for ; Fri, 6 May 2005 08:40:32 +0000 (GMT) Received: from mail.gmx.net (pop.gmx.net [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 68A1852AA2 for ; Fri, 6 May 2005 05:40:29 -0300 (ADT) Received: (qmail invoked by alias); 06 May 2005 08:40:30 -0000 Received: from p5495F29D.dip.t-dialin.net (EHLO pikkewyn.bienenet) [84.149.242.157] by mail.gmx.net (mp009) with SMTP; 06 May 2005 10:40:30 +0200 X-Authenticated: #1074748 Date: Fri, 6 May 2005 10:40:30 +0200 From: Vortex To: pgsql-sql@postgresql.org Subject: Re: select within aggregate? Message-Id: <20050506104030.3e725437.vortex25@gmx.de> Organization: private X-Mailer: Sylpheed version 1.0.3 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.516 tagged_above=0 required=5 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200505/50 X-Sequence-Number: 21363 On Fri, 6 May 2005 13:34:26 +0530 "Ramakrishnan Muralidharan" wrote: > SELECT abc.remote_host , c , abc.request_uri , a.t FROM abc , ( select remote_host , count(*) as c , max( ts ) as t from abc group by remote_host ) as a > where a.remote_host = abc.remote_host and abc.ts = a.t I thought about this too. But what happens if there are accidentally two sets with same timestamp in the table? I suppose the outer select would match both of them. But a DISTINCT should help to avoid this. Ok, if you think this is the propper way to meet the requirement i will do so. Thank you for your answer! Klaus