How to list the highest salary among all employee functions?

Asked

Viewed 5,600 times

3

Guys, I want to know how do I list only the function that has the highest salary and not the highest salaries of all functions, does anyone give me a light? Go on like I’m doing:

select max(Salario) from Funcionarios group by Funcao;

I also did so:

select max(Salario) from Funcionarios;

And that’s the last way I want it. I want to display the highest salary of all functions and also the name of this function that has the highest salary, but I do not know how to do.

  • If there is more than one function with the same salary, how will it be treated? It is to display all?

  • I hadn’t thought of that possibility. In the example I did, I put different salaries.

  • Exactly, Higor’s answer solves your problem but this situation may occur.

1 answer

4


SELECT funcao from Funcionarios WHERE salario = (select max(salario) from Funcionarios);

probably has a better solution than this, but at the moment I can not think of any :D

  • I’ll test =) Thanks.

  • 'select function, Salario from Employees Where salario = (select max(Salario) from Employees);' I made a small change, thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.