silversurfer19
Registered User.
- Local time
- Today, 17:26
- Joined
- Aug 20, 2008
- Messages
- 26
Hi,
I am trying to write a query which aggregates data from a table by year, month and postcode, then produces info:average price of houses sold that year, min price, max price and median price. I've got functions for all of these, but the Median function I'm using is causing problems. If I use it a normal select query it works fine, but as soon as I try to use it as part of the group query it complains that I tried to exectute a query that does not contain MEDIAN(decPrice) as part of an aggregate function. I get the same message if I use MedianPrice. Fair enough, but it doesn't complain about this for any of the other functions, and if I do group by MEDIAN(decPrice) it says 'data mismatch in expression'
Here's the offending query, I'd appreciate any advice anyone can offer.
I am trying to write a query which aggregates data from a table by year, month and postcode, then produces info:average price of houses sold that year, min price, max price and median price. I've got functions for all of these, but the Median function I'm using is causing problems. If I use it a normal select query it works fine, but as soon as I try to use it as part of the group query it complains that I tried to exectute a query that does not contain MEDIAN(decPrice) as part of an aggregate function. I get the same message if I use MedianPrice. Fair enough, but it doesn't complain about this for any of the other functions, and if I do group by MEDIAN(decPrice) it says 'data mismatch in expression'
Here's the offending query, I'd appreciate any advice anyone can offer.
Code:
SELECT application_year, application_month, postout, AVG(decPrice) AS AvgDecPrice, MAX(decPrice) AS MaxDecPrice, MIN(decPrice) AS MinDecPrice, MEDIAN(decPrice)
FROM DatesSplit
GROUP BY postout, application_year, application_month, MEDIAN(decPrice)
ORDER BY application_Year, application_month, postout;