子查询返回的值超过1个。当子查询遵循=,!=,<,<=,>,> =或将子查询用作表达式时,不允许使用此值

时间:2019-04-11 02:10:35

标签: mysql

执行查询时,出现以下问题。

  

错误:子查询返回了多个值。当子查询遵循=,!=,<,<=,>,> =或将子查询用作表达式时,不允许这样做。

     

错误:执行查询“

DECLARE @@Temp_table TABLE
(
ROWNUM INT NOT NULL...
     

”失败,并出现以下错误:“语句已终止。”。可能的失败原因:查询问题,“ ResultSet”属性未正确设置,参数未正确设置或连接未正确建立。

-- DROP Table Block

DROP TABLE IF EXISTS YEAR_DATA_FUNC_RESULT
GO


DECLARE @@Temp_table TABLE
(
ROWNUM INT NOT NULL IDENTITY PRIMARY KEY,MEMBER VARCHAR(15),YR_MONTH int
)
DECLARE @@OUT_PUT TABLE
(
    MEMBER VARCHAR(15),
    YR_MONTH int,
    LICS VARCHAR(5)
)

select distinct @

insert into @@Temp_table select distinct Member_Id,YEAR(SPlit_by_Month) as 'Year' from MEMBERS_BENEFIT

DECLARE @@ROWNUMBER INT = (SELECT COUNT(*) FROM @@Temp_table)

DECLARE @@COUNT INT=1
WHILE @@COUNT<=@@ROWNUMBER
BEGIN
    DECLARE @MEMBER VARCHAR(15)=(SELECT MEMBER FROM @@Temp_table WHERE ROWNUM=@@COUNT)
    DECLARE @YEAR VARCHAR(15)=(SELECT YR_MONTH FROM @@Temp_table WHERE ROWNUM=@@COUNT)
    INSERT INTO @@OUT_PUT SELECT * FROM LICS_UPDATE(@MEMBER,@YEAR)

    SET @@COUNT=@@COUNT+1
END

select * into YEAR_DATA_FUNC_RESULT from
(SELECT * FROM @@OUT_PUT ) a​

0 个答案:

没有答案