我当前组织的财政年度不等于当前日历年,因此 7 月 1 日实际上是 2014 年的第 1 个月。
给定以下sql:
SELECT *
FROM (
SELECT F.id, F.account, F.Pd AS Period, F.Actual AS Totals,
C.PROJ_NAME
FROM Foo.FinalData F
INNER JOIN Foo.ProjectCustom C
ON F.id = C.id
WHERE F.id LIKE '61000.001.001.%'
AND F.Account NOT LIKE '%-01'
AND `F.fy = DATEADD(yy, +1, GetDate())`
) Budget
PIVOT (
SUM(Totals) FOR Period in ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])
) AS PivotTable;
我如何编写查询以了解 7 月 1 日相当于新的当年?