Hi experts! I’m new to PL/SQL and currently facing the following issue:
I’m trying to transform the data from the database, which looks like this:
ID Date SalesForecast
111 13.06.17 100
111 14.06.17 110
111 15.06.17 90
222 13.06.17 50
333 14.06.17 100
333 15.06.17 100
... into something like that:
(13.06.17) (14.06.17) (15.06.17)
ID SalesForecastDay1 SalesForecastDay2 SalesForecastDay3
111 100 110 90
222 50 0 0
333 0 100 100
I already achieved this result by using a pivot clause. However, the dates are dynamic, which means SalesForecastDay1 should be sysdate / SalesForecastDay2 = sysdate + 1 / SalesForecastDay3= sysdate +2
Since this is kinda hard to realize in a pivot clause, I was wondering whether there is a different approach to solve this problem.
If you guys have any ideas or maybe an idea what to google for, I would be very grateful for any advice!
Many thanks!