Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 28th, 2008, 06:58 AM
Newbie
 
Join Date: Aug 2008
Posts: 1
Default SQL : nth highest salary from emp table

select distinct (a.salary) from employees a
where &N = (select count (distinct(b.salary))
from employees b where a.salary <= b.salary);

Pls any one explain how the query works, logic behind it.
Reply
  #2  
Old August 28th, 2008, 09:28 AM
Administrator
 
Join Date: Sep 2006
Posts: 11,312
Default

Which part don't you understand? Split it up and try to understand each part separately first.
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles