根据帮助请求,提示和建议,我已潜伏多年。现在是我问的时候了。我正在尝试创建一个运行求和查询字段。我会返回按月日期分组的发票总额。但是,我希望结果表中有一个会计年度(按月)。
到目前为止,这是我的代码:
SELECT
[Regions - Branches].City AS Branch,
[Regions - Branches].Region,
[Z Market Table].[CMarket],
[Z Market Table].[Market Segment],
[Time-Table].[Fiscal Year],
Sum([dbo_a Table - SQL Invoice Level].[Invoiced Sales]) AS [SumOfInvoiced Sales],
[Time-Table].Month INTO [Factors - SW Sales]
FROM [Z Market Table] INNER JOIN ([Time-Table] INNER JOIN ([Regions - Branches] INNER JOIN [dbo_a Table - SQL Invoice Level]
ON [Regions - Branches].[Branch Number] = [dbo_a Table - SQL Invoice Level].[Sales Office])
ON [Time-Table].[Date] = [dbo_a Table - SQL Invoice Level].[Invoice Date])
ON [Z Market Table].SIC = [dbo_a Table - SQL Invoice Level].Industry
GROUP BY
[Regions - Branches].City, [Regions - Branches].Region,
[Z Market Table].[Core Market],
[Z Market Table].[Market Segment],
[Time-Table].[Fiscal Year],
[Time-Table].Month
HAVING ((([Regions - Branches].Region)="SW") AND (([Time-Table].[Fiscal Year])=2015) AND (([Time-Table].Month)=9
Or ([Time-Table].Month)=8
Or ([Time-Table].Month)=7
Or ([Time-Table].Month)=6
Or ([Time-Table].Month)=5
Or ([Time-Table].Month)=4))
ORDER BY [Regions - Branches].City;
我一直在找一些来源,例如this:
但是,当我已经计算出总和时,我不确定它是如何应用的。
非常感谢任何想法和建议!
此致 RD