WHOOPS! With 17 weeks. I would *NOT* do this with SQL.
I would definitely do the consolidations in the PHP code.
I wouldn't go past 2 or 3 weeks with the above scheme.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.