I’m trying to figure out how to list tuples in SQL with the largest specific attributes. For example, say I have table:
Cars(make, model, year, engineSize, pistonCapacity)
and I want to list the tuple(s) with the largest piston capacity.
For example, lets say we have:
Lexus, SC430 , 1997, 6, 3.8 Ford , Mustang, 1986, 8, 5.0 GMC , Denali , 2009, 8, 6.5 Ford , F350 , 2009, 8, 6.5
I would want to list the GMC Denali and the Ford F350. I tried this query:
SELECT make, model
FROM Cars
ORDER BY pistonCapacity DESC limit 1
which lists only the GMC Denali.
I then tried this query:
SELECT make, model
FROM Cars
HAVING MAX(pistonCapacity)
but no luck.
Can anyone point me in the right direction?
Thanks for your help in advance!
1 Answer