Re: Simple Question!

From: L. Scott Johnson <sjohnson_at_math.scarolina.edu>
Date: 1995/04/25
Message-ID: <3njf7k$5rq_at_redwood.cs.scarolina.edu>#1/1


tmaxwell_at_crl.com (Anthony B. Cillo) writes:

>I am trying to find the oldest 1000 patients in our database. The
>problem is that I cannot get the system to stop after returning 1000
>rows. I have tried using rownum but that only works if you are not
>using order by.
 

>Any ideas?

Idea:

select * from patient master
where 1000 < (

	select count(*) from patient slave
	where slave.age > master.age

)

(may return a few more if there is a tie for 1000th oldest, of course) May need to tune the strict inequalities to allow equal, depending.

--
L. Scott Johnson (sjohnson_at_math.scarolina.edu) 
Graphics Specialist and Jyhad Rules' Monger.
Received on Tue Apr 25 1995 - 00:00:00 CEST

Original text of this message