我正在尝试使用以下内容在MSSQL 2012中编译子查询以提取导入货件中的容器卷
SELECT TOP (100) PERCENT JobShipment_1.JS_UniqueConsignRef, JobContainer_1.JC_ContainerNum,
(SELECT dbo.JobPackLines.JL_ActualVolume
FROM dbo.JobPackLines INNER JOIN
dbo.JobShipment ON dbo.JobPackLines.JL_JS = dbo.JobShipment.JS_PK INNER JOIN
dbo.JobContainerPackPivot ON dbo.JobPackLines.JL_PK = dbo.JobContainerPackPivot.J6_JL INNER JOIN
dbo.JobContainer ON dbo.JobContainerPackPivot.J6_JC = dbo.JobContainer.JC_PK) AS Expr1
FROM dbo.JobConsol INNER JOIN
dbo.JobConShipLink ON dbo.JobConsol.JK_PK = dbo.JobConShipLink.JN_JK INNER JOIN
dbo.JobShipment AS JobShipment_1 ON dbo.JobConShipLink.JN_JS = JobShipment_1.JS_PK INNER JOIN
dbo.cvw_JobShipmentOrgs ON JobShipment_1.JS_PK = dbo.cvw_JobShipmentOrgs.JS_PK INNER JOIN
dbo.JobContainer AS JobContainer_1 ON dbo.JobConsol.JK_PK = JobContainer_1.JC_JK INNER JOIN
dbo.JobDeclaration ON JobShipment_1.JS_PK = dbo.JobDeclaration.JE_JS
但是得到以下错误
“错误消息:子查询返回的值超过1。当子查询跟随=,!=,<,< =,>,> =或子查询用作表达式时,不允许这样做。 “
我在网上看起来很恶心,但无法找到答案,有人可以帮忙吗? 非常感谢
答案 0 :(得分:0)
尝试此查询
Inspector Panel
答案 1 :(得分:0)
请尝试以下:
SELECT TOP (100) PERCENT JobShipment_1.JS_UniqueConsignRef, JobContainer_1.JC_ContainerNum,
(SELECT JPL.JL_ActualVolume
FROM dbo.JobPackLines AS JPL
INNER JOIN dbo.JobShipment AS JS ON JS.JS_PK = JPL.JL_JS
INNER JOIN dbo.JobContainerPackPivot AS JCP ON JCP.J6_JL = JPL.JL_PK
INNER JOIN dbo.JobContainer AS JC ON JC.JC_PK = JPL.J6_JC) AS Expr1
FROM dbo.JobConsol
INNER JOIN dbo.JobConShipLink ON dbo.JobConsol.JK_PK = dbo.JobConShipLink.JN_JK
INNER JOIN dbo.JobShipment AS JobShipment_1 ON dbo.JobConShipLink.JN_JS = JobShipment_1.JS_PK
INNER JOIN dbo.cvw_JobShipmentOrgs ON JobShipment_1.JS_PK = dbo.cvw_JobShipmentOrgs.JS_PK
INNER JOIN dbo.JobContainer AS JobContainer_1 ON dbo.JobConsol.JK_PK = JobContainer_1.JC_JK
INNER JOIN dbo.JobDeclaration ON JobShipment_1.JS_PK = dbo.JobDeclaration.JE_JS