子查询返回的值超过1个

时间:2019-05-09 04:49:59

标签: sql

我有一个子查询,给我错误:

  

子查询返回了多个值

我要去哪里错了?

CASE WHEN @fund LIKE '123%'    
                THEN 
                        (SELECT ((SELECT (Nav.valueFund) 
                        FROM Nav WHERE fund = @fund and navDate = @navdate AND classification = 'Investments')
                        / ((SELECT ((SELECT SUM(Nav.valueFund) FROM Nav WHERE fund = @fund and navDate = @navdate))
                        + (SELECT LiqS.Amount FROM LiqS WHERE fund = @fund and Date = @navdate))))*100)                   
    ELSE (enav.exposureFundPerNAV) *100

1 个答案:

答案 0 :(得分:0)

第一个子查询(SELECT Nav.valueFund)没有使用诸如{{1}之类的函数的聚合函数来产生单个结果(如我们在第二个查询SELECT SUM(Nav.valueFund)中看到的) },SUMMAX(适用于第一个子查询)可以消除错误,否则MIN只能得到一个结果。