This is driving me nuts. I do hope someone can help this poor old duffer out.
Let's say we have the following two column database of city daily temperatures for a certain month. We can assume no two temperatures will ever be exacty the same. We don't know how many cities or rows there are:
London 20.1
Boston 15.5
Lincoln 18.1
Lincoln 13.0
London 21.1
Lincoln 12.9
Boston 17.6
London 20.3
If I do the following query:
select CITY, max(TEMP) MAXTEMP
from DATABASE
group by CITY
I will get:
CITY MAXTEMP
London 21.1
Boston 17.6
Lincoln 18.1
That's fine. Now let's say, out of those, I want the row with the MINIMUM temperature,.i.e.
Boston 17.6
I thought if I put the above query into a subquery, this would work:
select CITY, min(MAXTEMP)
from
(select CITY, max(TEMP) MAXTEMP
from DATABASE
group by CITY)
but it is syntactically incorrect. What am I doing wrong please?
Thanks.
Paul.