Like the title says I need to have a final result where on one line I have
year- month and week…
Something like that:
------------------------
| Year | Month | Week |
| 2012 | 1 | 1 |
| 2012 | 1 | 2 |
| 2012 | 1 | 3 |
| 2012 | 1 | 4 |
| 2012 | 1 | 5 |
| 2012 | 2 | 5 |
And so on…
Is it possible to generate a view like this (also using some support table)?
You can do it with a stored procedure:
Then do a
call createDatesTable()and you will have your table filled.
Important: ypercube’s comment is right. You have to consider this. So have a look at the WEEK() function and its supported modes. Adjust the procedure accordingly.