Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A very simple but complicated SQL statement.
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00081329
Message ID:
00081633
Views:
28
>>>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 .
>>
>>Hello Satya,
>>
>>Try this
>>
>>    SELECT e.name, ,
>>         (SELECT e1.sal
>>          FROM employee AS e1
>>          WHERE (blah - enter your 'where clause' here) ) AS rank
>>      FROM employee AS e
>>      WHERE rank <= 5;
>>
>>
>>This was taken from the Q&A section of an excellent site called the SQL PRO at
>>http://www.inquiry.com/techtips/thesqlpro/index.html
>>
>>Steve
>
>Steve, if you'll read this whole thread, you find out that UT is also excellent site.

Sorry Edward, I didn't know there was only allowed one excellent site on the net (big grin).

Steve
Steve Peacocke
Development Team Leader
Prudential Assurance
Previous
Reply
Map
View

Click here to load this message in the networking platform