Re: Simple Question!
Date: 1995/04/29
Message-ID: <26_at_along.dialix.oz.au>#1/1
In article <3nio5g$1j7_at_dcsun4.us.oracle.com>, Carl Gohringer (cgohring_at_lucifer) writes:
>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?
>:
>Use a PL/SQL block
>
>
>--
>regards,
>Carl
>+-----------------------------------------------------------------------------+
>Carl Gohringer, Oracle European Development Centre, World Wide Education
>Oracle Park, Bittams Lane, Chertsey, Surrey, England, KT16 9RG
>Internet : cgohring_at_uk.oracle.com
>+-----------------------------------------------------------------------------+
Hello carl,
Try this,
SELECT AGE FROM TABLE
ORDER BY AGE
WHERE ROWNUM <= 1000;
That way, you order by age, returning the ages in ASC or DESC order depending on your chaoice, and filed, AGE_IN_YEARS or DATE_OF_BRITH, and the WHERE statement will stop the query when you've reached 1000 rows.
Regards,
Alex Long
-- , \ / , / \ )\__/( / \ / \ (_\ /_) / \ ______________________/_____\__\_at_ @/___/_____\________________ |paladin.along.dialix.oz.au | |Alex Long | |Adelaide, South Australia | |_______________________________________________________________| |Wiv a ladder and some glasses, | |You copuld see to 'Ackney Marshes, | |If it wasn't for the 'ouses in between. | |Edgar Bateman | +_______________________________________________________________+ | /\ / \\ \ /\ | | / V )) V \ | |/ ` // ' \| ` V ' _Received on Sat Apr 29 1995 - 00:00:00 CEST