[英]How to resolve Subquery returned more than 1 value error
I'm trying to execute this stored procedure 我正在尝试执行此存储过程
ELSE IF(@Item_Type='Frames')
BEGIN
SELECT
ID.Selling_Price, --0
ID.Purchase_Price,--1
@Discount AS Discount,--2
IH.Item_Name AS Item_Group_Name,--3
@Item_Group_Code AS Item_Group_Code,--4
FD.Item_Code,
ID.Item_Name,
FD.Material,
FD.Color,
FD.RIM,
FD.Frame_Code
FROM
Frame_Details AS FD
LEFT JOIN
Item_Details AS ID ON FD.Item_Code = ID.Item_Code
LEFT JOIN
Item_Header AS IH ON IH.Item_G_Code = ID.Item_G_Code
WHERE
FD.Status = '0'
AND FD.Item_Code = @Item_Code
GROUP BY
ID.Selling_Price, ID.Purchase_Price, IH.Item_Name,
FD.Item_Code, ID.Item_Name, FD.Material, FD.Color, FD.RIM, FD.Frame_Code
END
it will not execute successfully..this is the error message that I got 它不会成功执行..这是我收到的错误消息
Subquery returned more than 1 value.
子查询返回的值超过1。 This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
当子查询遵循=,!=,<,<=,>,> =或将子查询用作表达式时,不允许这样做。
I have tried several examples given before, but they don't works for me. 我已经尝试了几个示例,但是它们对我不起作用。
It seems that the subquery returns more than one records. 看来子查询返回了多个记录。 In this case, the result is a set, not a single value, while which is not allowed in your scenario.
在这种情况下,结果是一个集合,而不是单个值,但是在您的方案中是不允许的。 To avoid this issue, you may have a try to join the result of this subquery, or use TOP 1 or max or sum or AVG to return only one value.
为避免此问题,您可以尝试加入此子查询的结果,或使用TOP 1或max或sum或AVG仅返回一个值。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.