Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A very simple but complicated SQL statement.
Message
From
26/02/1998 09:53:36
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00081329
Message ID:
00081360
Views:
22
>>>>I am using ORACLE 7.3 .
>>>>
>>>>I have one table "employee" with a column "sal" .
>>>>I have inserted the data into the sal in random order.
>>>>Now I want to retrive the rows from that table who draw the maximum salary. (sal).
>>>>
>>>>That is first 5 records after the list is selected by using "order by desc " clause.
>>>>
>>>>I want to use single SQL statement.
>>>>
>>>>some thing like this algorithm.
>>>>
>>>>select first 5 records from ("select sal from employee order by sal desc " )
>>>>
>>>>I tried to use rownum, count() etc. but in fail.
>>>>
>>>>I dont want to use Foxpro .
>>>>
>>>>
>>>>--Satya
>>>
>>>If you would want to use Foxpro then SELECT TOP 5 .... will do this job. If you don't want to use Foxpro, then what is a purpose to post this question on Foxpro forum?
>>
>>
>>I am using ODBC support to connect oracle with VFP. And don't want to use one more query to get top 5 records that have been fetched by the SQLexec command.
>
>There is no *Select top* for an Oracle query. You would have to do:
>
>sqlexec(nHandle,"select sal from employee order by sal desc","MyCursor")
>select top 5 from mycursor

In SQL-Server you can set @@ROWCOUNT to 5 to retrieve just 5 record once. I don't use Oracle, but guess something similar should be there.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform