TOP FOUR SALARIES OF AN EMPL0YEE [message #421297] |
Mon, 07 September 2009 06:20 |
mohannksr
Messages: 28 Registered: January 2009
|
Junior Member |
|
|
Hi,
i am using the following query
SELECT emp_id,
salary,
(CASE
WHEN DENSE_RANK () OVER (ORDER BY salary DESC) = 1
THEN
'first'
WHEN DENSE_RANK () OVER (ORDER BY salary DESC) = 2
THEN
'second'
WHEN DENSE_RANK () OVER (ORDER BY salary DESC) = 3
THEN
'third'
WHEN DENSE_RANK () OVER (ORDER BY salary DESC) = 4
THEN
'four'
END)
AS rank1
FROM employee
WHERE salary > 0
to fetch the employee id and their salary in descending order.
Is there any way to limit the number of records to highest four salary in the same query itself...?by giving some where conditions...?
|
|
|
Re: TOP FOUR SALARIES OF AN EMPL0YEE [message #421300 is a reply to message #421297] |
Mon, 07 September 2009 06:25 |
|
Michel Cadot
Messages: 68722 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Top queries are a FAQ, please search BEFORE posting.
From your previous topics:
BlackSwan wrote on Wed, 13 May 2009 16:28 | ...
You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Go to the URL above click the link "Posting Guidelines"
Go to the section labeled "Practice" & do as directed.
|
Michel Cadot wrote on Fri, 17 April 2009 08:46 | ...
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and use code tags.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).
Regards
Michel
|
[Updated on: Mon, 07 September 2009 06:25] Report message to a moderator
|
|
|