Home » SQL & PL/SQL » SQL & PL/SQL » how to find TOP 5 employee record (windows)
how to find TOP 5 employee record [message #386436] Sat, 14 February 2009 21:52 Go to next message
dbhossain
Messages: 155
Registered: August 2007
Location: Dhaka
Senior Member

can any one help me please, i need a query to show top 5 salary holder detials from EMP table.


please help me.


Thank you.
Re: how to find TOP 5 employee record [message #386437 is a reply to message #386436] Sat, 14 February 2009 21:54 Go to previous messageGo to next message
dr.s.raghunathan
Messages: 540
Registered: February 2008
Senior Member
use descending and row_number
Re: how to find TOP 5 employee record [message #386438 is a reply to message #386436] Sat, 14 February 2009 21:55 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
So we can help you

This is a FAQ so SEARCH for previously posted solutions
Re: how to find TOP 5 employee record [message #386439 is a reply to message #386436] Sat, 14 February 2009 21:56 Go to previous messageGo to next message
dbhossain
Messages: 155
Registered: August 2007
Location: Dhaka
Senior Member

Thank you. i thought as it is. and i am successful now Smile .


Re: how to find TOP 5 employee record [message #386440 is a reply to message #386436] Sat, 14 February 2009 21:58 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
From Posting Guidelines

"If you found an answer yourself, post it. That way we know the issue is resolved and others might learn from it."
Re: how to find TOP 5 employee record [message #386441 is a reply to message #386440] Sat, 14 February 2009 22:29 Go to previous messageGo to next message
m_golam_hossain
Messages: 89
Registered: August 2008
Location: Uttara, Dhaka, Bangladesh
Member

Mr. DBHossain,

This is the shortest query, I think:

SELECT empno, salary
FROM
(SELECT empno, salary, rownum
FROM emp
ORDER BY salary DESC
)
WHERE rownum<=5;

Thanks-

Mohd. Golam Hossain
Uttara, Dhaka, Bangladesh.

[Updated on: Sat, 14 February 2009 22:32]

Report message to a moderator

Re: how to find TOP 5 employee record [message #386445 is a reply to message #386441] Sun, 15 February 2009 01:16 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
@m_golam_hossain,
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), use code tags.
Use the "Preview Message" button to verify.

Also, don't put solution only hint or clue as requested in OraFAQ Forum Guide, "Responding to Posts" section:
Quote:
When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, especially in the homework and newbies forums, it is usual to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, and not provide complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.


Regards
Michel

[Updated on: Sun, 15 February 2009 01:17]

Report message to a moderator

Re: how to find TOP 5 employee record [message #386454 is a reply to message #386445] Sun, 15 February 2009 03:15 Go to previous message
m_golam_hossain
Messages: 89
Registered: August 2008
Location: Uttara, Dhaka, Bangladesh
Member

Lots of thanks with best regards for the suggestions.

[Updated on: Sun, 15 February 2009 03:18]

Report message to a moderator

Previous Topic: Converting duplicate data to one row
Next Topic: grouping rows based on values
Goto Forum:
  


Current Time: Thu Dec 08 16:41:53 CST 2016

Total time taken to generate the page: 0.06786 seconds