I want to make a forecast based on weeks.
I have the table like this.
personName, year, week1, ..., week52.
And would like to add the next year to columns based on how much week i need.
Some kind of select in select.
The final select should look like this:
select personName, week1,week2,..., (nextyear)week1,(nextyear)week2,.. from x
Any ideas how can I move the next year up to columns?
You want to make rows for your data instead of columns – for the exact reason that you are asking about.
Something like this structure:
Then you can do a query like:
or pure SQL like this:
However, this similar approach could be used with your table something like this: