简体   繁体   English

如何解决子查询返回超过1个值的错误

[英]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.

相关问题 发生此错误的原因:子查询返回了多个值 - Why this error occurs: Subquery returned more than 1 value 如何汇总数据库中给定日期的多个时间记录。 错误:子查询返回的值超过1 - How to sum up multiple time records on a given date in database. Error:Subquery returned more than 1 value SQLCLR程序集上的“子查询返回了多个值” - “Subquery returned more than 1 value” on SQLCLR Assembly SqlException因为子查询返回了多个值 - SqlException because Subquery returned more than 1 value SQL Server 中的子查询返回了 1 个以上的值 - A subquery in SQL Server returned more than 1 value 子查询返回了 1 个以上的值。 当子查询跟随 =、!=、&lt;、&lt;=、&gt;、&gt;= 时,这是不允许的 - Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= C#返回错误“子查询返回的值大于1”,但这应该可以 - C# returns error 'Subquery returned more than 1 value' but that should be ok 为什么DbContext.SaveChangesAsync引发“子查询返回多个值”错误? - Why is DbContext.SaveChangesAsync throwing a “Subquery returned more than 1 value” error? 子查询返回了多个值。.查询C#异常 - Subquery returned more than 1 value.. query C# exception 子查询在C#foreach循环中返回了多个值 - Subquery returned more than 1 value in C# foreach loop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM