Received: from linux2.johnmckown.net (adsl-64-216-0-28.dsl.eulstx.swbell.net [64.216.0.28]) by hub.org (8.10.1/8.10.1) with ESMTP id e7S3vqL12309 for ; Sun, 27 Aug 2000 23:57:52 -0400 (EDT) Received: from linux2 (IDENT:jmckown@linux2 [192.168.151.21]) by linux2.johnmckown.net (8.10.1/8.10.1) with ESMTP id e7S3vuh15411; Sun, 27 Aug 2000 22:57:56 -0500 Date: Sun, 27 Aug 2000 22:57:56 -0500 (CDT) From: John McKown X-Sender: jmckown@linux2.johnmckown.net To: Stephan Szabo cc: Paulo Roberto Siqueira , PGSQL SQL Subject: Re: Select subset of rows In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200008/294 On Sun, 27 Aug 2000, Stephan Szabo wrote: > > Of course immediately after sending the last message and logging off my > ISP I figured out the simpler way for the third one: > > begin; > select salary into temp saltemp from employee order by salary desc > limit 5; > select name from employee where exists (select * from saltemp where > saltemp.salary=employee.salary); > end; > > Stephan Szabo > sszabo@bigpanda.com > I wonder if the following might be a bit faster? Or would it be slower? select salary into temp saltemp from employee order by salary desc limit 5; select min(salary) as minsal into test minsal from saltemp; select name, salary from employee, minsal where salary >= minsal; I don't know the speed difference between my second select and your subselect within an EXISTS clause might be. Just a thought, John