I'm trying to get a Dynamic PIVOT query in 12c working but am struggling to find the correct solution. In this case weeks 40-43 would be columns but as the month changes so will the weeks.
PIVOT XML works with the data but obviously in an XML format, not acceptable, so I'm looking for some alternative solutions and ideas????
Thanks,
The report is period/week based (stripped down here)
SELECT STORE, NET_SALES, WEEK
FROM Table A
PIVOT
(
SUM(NET_SALES)
FOR WEEK IN (40,41,42,43)
)
ORDER BY STORE;
Subquery for IN Clause…
SELECT DISTINCT(CT.WK_OF_YEAR)
FROM CALENDAR CT
WHERE CT.PERIOD_NO = '10'
and CT.THEYEAR = '2017'
ORDER BY CT.WK_OF_YEAR