0
我有一個sql查詢,顯示一列中的年份和另一列中的月份。我可以將報告顯示爲當年,但我需要以財政形式顯示,例如我們的財政年度是從十月十日開始的,所以我如何在sql中執行此操作?我下面當前查詢:報告中的SQL財年
SELECT TOP (15) dbo.timelinedayres_v1_0.fiscalyear,
dbo.timelinedayres_v1_0.fiscalmonth,
SUM(dbo.factqht_v2.baanstandarcost) AS stdcost,
CAST(dbo.timelinedayres_v1_0.fiscalmonth AS VARCHAR) + ' - ' +
CAST(dbo.timelinedayres_v1_0.fiscalyear AS VARCHAR) AS CONCAT
FROM dbo.timelinedayres_v1_0
INNER JOIN dbo.factqht_v2
ON dbo.timelinedayres_v1_0.epoch = dbo.factqht_v2.qhtwfclosedtimekey
INNER JOIN dbo.dimqht_v2
ON dbo.factqht_v2.qhtid = dbo.dimqht_v2.qhtid
LEFT OUTER JOIN dbo.dimqhtmaterials_v2
ON dbo.factqht_v2.materialid = dbo.dimqhtmaterials_v2.materialid
LEFT OUTER JOIN dbo.dimqhtdispositions_v2
ON dbo.factqht_v2.dispositionid =
dbo.dimqhtdispositions_v2.dispositionid
GROUP BY dbo.dimqhtdispositions_v2.TYPE,
dbo.timelinedayres_v1_0.fiscalyear,
dbo.timelinedayres_v1_0.fiscalmonth,
dbo.dimqht_v2.toplevelassembly_majoritemgroupdesc,
CAST(dbo.timelinedayres_v1_0.fiscalmonth AS VARCHAR) + ' - ' +
CAST(dbo.timelinedayres_v1_0.fiscalyear AS VARCHAR)
HAVING (dbo.dimqhtdispositions_v2.TYPE = N'Scrap')
AND (dbo.dimqht_v2.toplevelassembly_majoritemgroupdesc =
'Torquer Motors')
ORDER BY dbo.timelinedayres_v1_0.fiscalmonth