My query below returns however many rows fit the WHERE condition, in this case when they year, period, week is <= 2009131. In my case it is returning 11 rows because I have 11 rows where the year,period, week is 2006XXX. However, this is not what I want. I only need 4 rows returned to me and not all 11 no matter what the <= XXXXXXX part of the where is.
I guess my question becomes is it possible to put a LIMIT of how many rows are returned on a GROUP BY? Thanks! SELECT ROUND(AVG(page_hit)) as page_hit, ROUND(AVG(training_tracking)) as training_tracking, ROUND(AVG(certificates)) as certificates, ROUND(AVG(team_members)) as team_members, ROUND(AVG(evaluation)) as evaluation, CONCAT(year,period,week) as date FROM statistics WHERE CONCAT(year,period,week) <= 2009131 AND region_id != 'AA' GROUP BY date ORDER BY date DESC LIMIT 0,77