请帮我解决这个问题 [英] Please help me to solve this
本文介绍了请帮我解决这个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
查询
Query
select distinct A.Doctype,A.DocNo ,A.Docdate ,ex_asses=(Select sum(P.TaxAbleAmt) from CMTaxRegister P where P.TaxType='vat' and A.DocNo=P.DocNo ),
ex_value=(Select sum(P.TaxAmt) from CMTaxRegister P where P.TaxType='vat' and A.DocNo=P.DocNo ),
ex_duty=(Select P.TaxRate from CMTaxRegister P where P.TaxType='vat' and A.DocNo=P.DocNo),
sal_kay=(Select top(1) (Q.Txauthdesc) from CMTaxRegister P inner join CMTAXATH Q on P.TaxAuthority= Q.Txauthkey where P.TaxType='Flat' and A.DocNo=P.DocNo and A.DocLinNo=P.DocLinNo),
SalTaxVal=(Select sum(P.TaxAmt) from CMTaxRegister P where P.TaxType='Flat' and A.DocNo=P.DocNo )
from CMTaxRegister A where DocNo='IEPL/15-16/0012'
我的尝试:
错误
消息512,级别16,状态1,行4
子查询返回的值超过1。当子查询遵循=,!=,<,< =,>,> =或子查询用作表达式时,不允许这样做。
What I have tried:
Error
Msg 512, Level 16, State 1, Line 4
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
推荐答案
正如错误msg所说,你不能将select的多个返回值分配给一个变量,可能的罪魁祸首就是这个:
As the error msg said, you cannot assign multiple returned values from select to a variable, the likely culprit is this one:
ex_duty=(
Select P.TaxRate from CMTaxRegister P where P.TaxType='vat' and A.DocNo=P.DocNo
)
似乎返回多个TaxRate。
好到请注意 SQL子查询的这些规则 [ ^ ]
seems to return multiple TaxRate.
Good to take note of these rules for SQL Sub Queries[^]
这篇关于请帮我解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文