错误:子查询返回了 1 个以上的值。当子查询跟在 =、!=、<、<= 、>、>= 之后时,不允许这样做



此处显示的查询在Description列中返回多行,并导致标题中提到的错误。

有什么建议吗?

SELECT 
T0.[TransId], T0.[Account], T0.[ShortName], T0.[ContraAct], 
CASE
WHEN T0.[TransType] = '18 '
THEN (SELECT Description FROM PCH1 
WHERE DocEntry = T0.CreatedBy AND AcctCode = T0.Account)
ELSE T0.[LineMemo]
END AS Description,
T0.[Ref3Line], T0.[TransType], T0.[RefDate], 
T0.[CreatedBy], T0.[BaseRef] 
FROM 
JDT1 T0 
WHERE 
T0.[Account] = '630000'

我猜您的子查询在返回了多条记录

(SELECT Description FROM PCH1 
WHERE DocEntry = T0.CreatedBy AND AcctCode = T0.Account)

您可以尝试为添加SELECT TOP 1

选择T0.[TransId],T0.[Account],T0.[ShortName],T0.[Contract],案例当T0.[TransType]='18'时然后(从PCH1中选择前1项描述其中DocEntry=T0.由AND AcctCode=T0.帐户创建(ELSE T0.[LineMemo]END AS描述,T0.[Ref3Line],T0.[TransType],T0.[RefDate],T0.[CreatedBy],T0.[BaseRef]来自JDT1 T0其中T0.[帐户]='630000'

希望有用由GoDevStack

相关内容

  • 没有找到相关文章