运行以下查询时,我得到了所需的结果,但是当我将鼠标悬停在表别名上并且将鼠标悬停在 AVG 函数中的“总计”上时,SSMS 指示“没有为 'MonthlyTotals' 的第 2 列指定任何列,它指定它是无效的列名。
SELECT AVG(Totals) as 'MonthlyAvg' from
(
SELECT [DATE], SUM(Assets) as 'Totals'
FROM Assets inner join Funds on Assets.FundCode = Funds.FundCode
WHERE FeeGroupID = 17
and (([Date] >= '1/1/2013')
AND ([Date] <= '4/1/2013'))
and ((Funds.EndDt >= '4/1/2013') OR (Funds.EndDt is null))
GROUP BY [DATE]
) as MonthlyTotals