metropia
asked on
Subquery returned more than 1 value
I need help debugging my query.
I get error:
Msg 512, Level 16, State 1, Line 5
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I do not know how to begin testing to see where the error come from exactly.
Please help.
I get error:
Msg 512, Level 16, State 1, Line 5
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I do not know how to begin testing to see where the error come from exactly.
Please help.
SELECT DISTINCT
sqcl.SalesQuoteNumber
, sqcl.ItemNumber
, (
SELECT DISTINCT
s.SalesQuoteNumber
FROM
cost.vStd_SalesQuoteCostLine s
WHERE
s.CustomerNumber_BillTo = sqcl.CustomerNumber_BillTo
AND
s.ItemNumber = sqcl.ItemNumber
AND
s.DocumentDate =
( SELECT MAX(s2.DocumentDate)
FROM cost.vStd_SalesQuoteCostLine s2
WHERE s2.CustomerNumber_BillTo = sqcl.CustomerNumber_BillTo
AND s2.ItemNumber = sqcl.ItemNumber
AND s2.DocumentDate < sqcl.DocumentDate
)
) AS PriorQuoteNumber
FROM
cost.vStd_SalesQuoteCostLine sqcl
WHERE
sqcl.SalesQuoteNumber = @SalesQuoteNumber
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER