我正在尝试使用“新命名查询”在 SSAS 的数据源视图中添加一个表。脚本如下所示:
Declare @AvgInvestment float;
SELECT @AvgInvestment=SUM(Investment)/COUNT(distinct meta_ID)
FROM AAAA
SELECT Player, Investment,
InvestmentRange=
Case When Investment >=0 AND Investment <(@AvgInvestment/3) THEN 1
When Investment >=(@AvgInvestment/3) AND Investment <(4*@AvgInvestment/3) THEN 2
When Investment >=(4*@AvgInvestment/3) AND Investment <(6*@AvgInvestment/3) THEN 3
When Investment >=(2*@AvgInvestment) THEN 4
END
FROM AAAA
但是,SSAS 不允许在 SQL Query for DVS 中声明变量。是否有任何可能的方法来修改 SQL 语句以使其没有变量?我尝试将 @AvgInvestment 替换为 "SELECT SUM(Investment)/COUNT(distinct meta_ID) FROM AAAA" ,但它不起作用。
感谢您提供任何可能的解决方案!