Re: I need a special SQL statement...
Date: 6 Jan 1995 03:13:27 GMT
Message-ID: <3eicgn$7nk_at_homer.alpha.net>
MDNatale (mdnatale_at_aol.com) wrote:
> I am developing an application that interfaces with a rather large oracle
> database. I have the need to query the top 25 values, and the low 25
> values. I know how to sort my data using 'order by', but how do I make it
> stop querying after the 25 values are recieved?
Using PRO C, declare an array of 25 then
EXEC SQL
SELECT fld_name
INTO array_of_25
FROM table_name
ORDER BY <you know how to get it?>
(Similar for bottom 25)
[Would raise an exception but thats ok, you would get the right result,
or you could say EXEC ORACLE SELECT_ERROR=NO)
Plain SQL
SELECT fld_name
FROM table_name
WHERE fld_name > ' ' -- would force the use of index (and there must be
an index to get order) AND rownum <= 25
[similar for bottom 25 but remember the indexes]
-- ************************************************************** * Saad Ahmad * * E-Mail: sahmad_at_mfa.com * **************************************************************Received on Fri Jan 06 1995 - 04:13:27 CET