Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 653089F9D63 for ; Mon, 20 Aug 2007 11:13:36 -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 97464-04-2 for ; Mon, 20 Aug 2007 11:13:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from coe.tamu.edu (edsun.coe.tamu.edu [165.91.232.6]) by postgresql.org (Postfix) with ESMTP id 409EA9F9D47 for ; Mon, 20 Aug 2007 11:13:31 -0300 (ADT) Received: (from root@localhost) by coe.tamu.edu (8.11.7p3+Sun/8.12.11) id l7KECLl28370 for pgsql-admin@postgresql.org; Mon, 20 Aug 2007 09:12:21 -0500 (CDT) Received: from coe.tamu.edu (coe.tamu.edu [165.91.232.6]) by coe.tamu.edu (8.11.7p3+Sun/8.12.11) with ESMTP id l7KE7kC28127; Mon, 20 Aug 2007 09:07:46 -0500 (CDT) Date: Mon, 20 Aug 2007 09:07:46 -0500 (CDT) From: Ben Kim To: giuseppe.derossi@email.it cc: pgsql-admin@postgresql.org Subject: Re: HELP, can't implement e filter In-Reply-To: <5721d54f0ab9128f6c815295a036b0f4@83.225.9.51> Message-ID: References: <5721d54f0ab9128f6c815295a036b0f4@83.225.9.51> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by AMaViS 0.3.12 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/222 X-Sequence-Number: 26553 On Sun, 19 Aug 2007, giuseppe.derossi@email.it wrote: > Hi, > I need to implement a filter in order to select from the first table the > second one... > c1 c2 c3 c4 c5 > 1)133659;1;"0039";"00121";7 > 2)133664;1;"0039";"00121";12 > 3)133664;2;"0039";"00121";12 > 4)133665;2;"0039";"00121";12 > 5)135460;1;"0039";"01152"; > 6)135460;2;"0039";"01152"; > 7)135471;1;"0050";"00153";4 > 8)135471;2;"0050";"00153";4 > > 1)133659;1;"0039";"00121";7 > 3)133664;2;"0039";"00121";12 > 4)133665;2;"0039";"00121";12 > 6)135460;2;"0039";"01152"; > 8)135471;2;"0050";"00153";4 There should be something better but this might work. select * from testtable where (c1,c2) in (select c1, max(c2) from testtable group by c1 ); HTH Ben K. Developer http://benix.tamu.edu