How to select name with the highest power and highest salary
Id | Name | Salary |
---|---|---|
1 | Kobe | 50000 |
2 | Lebron | 500099 |
3 | Steph | 628228 |
4 | Thompson | 50505 |
5 | Shabu | 393828 |
How to select name with the highest power and highest salary
Id | Name | Salary |
---|---|---|
1 | Kobe | 50000 |
2 | Lebron | 500099 |
3 | Steph | 628228 |
4 | Thompson | 50505 |
5 | Shabu | 393828 |
3
Answers
The CTE represents your table. The query you need is the last 3 lines, where it’s sorting the output by salary in descending order, then limiting to 1 row.
Output:
UPDATE
Per your comment about using a Max function, here’s one way, using a sub-query:
You can use a sub-query to to so
EDIT
Or you can just use
Expanding on 53RT’s comment, for MySQL: