Re: Top ten again?

From: David Bath <dtb_at_otto.bf.rmit.oz.au>
Date: 25 Apr 93 06:44:31 GMT
Message-ID: <dtb.735720271_at_otto>


I would create a temp table, use a PL/SQL cursor (with ORDER by the item you are interested in DESCENDING) from the source table and only take the first ten fetched rows to insert them into the temp table.
Then select out of the temp table.

ROWNUM gets calculated BEFORE sorting and ordering (unless you hack your statement to use an INDEX on the field you want and invalidate the others).

-- 
David T. Bath             | Email:dtb_at_otto.bf.rmit.oz.au (131.170.40.10)
Senior Tech Consultant    | Phone: +61 3 347-7511 TZ=AEST-10AEDST-11
Global Technology Group   | 179 Grattan St, Carlton, Vic, 3153, AUSTRALIA
"The robber of your free will does not exist" - Epictetus
Received on Sun Apr 25 1993 - 08:44:31 CEST

Original text of this message