SUM (CASE
WHEN T6.Currency =
(
SELECT A0.MainCurncy
FROM '+@myTempTableName+'.dbo.OADM A0
)
THEN T6.LineTotal
else T6.TotalFrgn
END) as [Mf.Amount],
我收到了这个错误:
无法对包含聚合或子查询的表达式执行聚合函数。
任何人都可以帮助我吗?
答案 0 :(得分:0)
您需要修复整体查询:
SELECT . . .
SUM(CASE WHEN A0.MainCurncy IS NOT NULL
THEN T6.LineTotal
ELSE T6.TotalFrgn
END) as [Mf.Amount],
FROM . . . LEFT JOIN
@myTempTableName+'.dbo.OADM A0
ON A0.MainCurncy = T6.Currency