Hi to everyone!
I'd need some help with this query:
I have to find the city with highest average price/mq of buildings with private use among cities of the same region.
This is what I've written till now:
Code:
SELECT address.region, address.city, AVG(announce.price/building.mq)
FROM announce JOIN building ON (announce.id_i = building.id_i)
JOIN address ON (building.id_i = address.id_i)
WHERE bulding.use = 'private' AND price IS NOT NULL
GROUP BY address.region, address.city
ORDER BY address.region, address.city
With this code I find the average price/mq for every city of every region.
Since I can't use something like MAX(AVG(announce.price/building.mq)) in Postgres,
how can I find a city for every region?!