The problem is that multiple rows can be merged to create each AVG
so you also need to find a way to combined the CreatedDate
values of those multiple rows into a single value. I think the only choices are MIN
or MAX
so use:
ORDER BY MIN(ClosedDate)
or:
ORDER BY MAX(ClosedDate)
in your first query.
PS
As Adrian identified, this doesn't work with the LIMIT term present. So remove that or if its important you will need to find a different answer.