Jump to content
Sign in to follow this  
Deyan8777

I need help guys

Recommended Posts

i got table employees with ID , NAME , SALARY 

i need to select all employees having max salary.

i need to self join the table and i must not use subselect. For now only 2 employees got the max salary how to select both of them

 

 

select e.name, max(e.salary)
from employees as e
left join employees as es 
on e.id=es.id
 this only select one of the employees having max salary i need and the other one 
Edited by Deyan8777

Share this post


Link to post
Share on other sites

Forget about max for this.

 

Think about what would happen if you joined the table against itself and with the condition that the second table's rows have a higher salary than the first table's...

Share this post


Link to post
Share on other sites

I know this will probably sound crazy to you, but how about reading the replies?

 

The solution is right in front of you. All you have to do is stop complaining and open your eyes.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.