MAX height

SELECT
first_name,
last_name,
height
FROM patients
WHERE height = (
SELECT max(height)
FROM patients
)
SELECT
first_name,
last_name,
height
FROM patients
WHERE height = (
SELECT max(height)
FROM patients
)
Why can't I just do WHERE height = MAX(height) The questions wants me to return the first, last name and height of the person with the highest height
2 Replies
sos
sosOP6mo ago
afaik, MAX(height) returns the max value of that column so I am not sure why it wouldn't work
Jochem
Jochem6mo ago
I think it's something pretty technical about aggregate functions and how they work. HAVING MAX(height) = height should work too. so not 'where having' but just 'having' or as a separate pause after a normal where
Want results from more Discord servers?
Add your server