I have a table i need to run reports on, so i need to run a cross tab query against it. I get to this far:
TRANSFORM Sum(dbo_PSALES.PeriodSales) AS SumOfPeriodSales
SELECT dbo_PSALES.UniqueID
FROM dbo_PSALES
GROUP BY dbo_PSALES.UniqueID
PIVOT dbo_PSALES.PeriodNo In (26,25,24,23,22,21);
Where the query runs fine, but as you can see i hardcoded the period numbers into the query. How do i turn it into a dynamic one? so everytime new period adds into the database query result will change also?
TRANSFORM Sum(dbo_PSALES.PeriodSales) AS SumOfPeriodSales
SELECT dbo_PSALES.UniqueID
FROM dbo_PSALES
GROUP BY dbo_PSALES.UniqueID
PIVOT dbo_PSALES.PeriodNo In (26,25,24,23,22,21);
Where the query runs fine, but as you can see i hardcoded the period numbers into the query. How do i turn it into a dynamic one? so everytime new period adds into the database query result will change also?