Reputation: 520
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. 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.
Upvotes: 0
Views: 380
Reputation: 521
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.
Thanks
Upvotes: 3