I have two select statements that find the maximum salary for a specific role. Now I want to have the maximum of the two returns of those select statements. Think about the following code:
SELECT MAX(SALARY)
FROM TABLE1
WHERE ROLE = 'MANAGER'
SELECT MAX(SALARY)
FROM TABLE1
WHERE ROLE = 'DEVELOPER';
At the end I want the maximum of these two numbers.
How would I do all this in one query?
Have two selects for maximum, then compare those maximums and give the maximum of the two maximums?
If you want maximum from more job titles, add that job title in "IN" array. No need to write one select statement for each job title.
SELECT MAX(SALARY) FROM TABLE1 WHERE ROLE IN ('MANAGER','DEVELOPER')
Since both selects read from the same table, you can do this:
SELECT MAX(SALARY) FROM TABLE1 WHERE ROLE = 'MANAGER' OR ROLE = 'DEVELOPER'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With