Hi @Yefer Bastidas
Sorry for not checking your code carefully yesterday.And as experts said ,there are indeed some subqueries in your code that may return more than 1 value.
As you can see from the error message,there are two situations that can cause this error.
First : when the subquery follows =, !=, <, <= , >, >=
and I believe you have double checked this situtuation.
Second : when the subquery is used as an expression
Please refer to this sample:
CREATE TABLE #TEST1(ID INT,Column_1 VARCHAR(10));
INSERT INTO #TEST1 VALUES(1,'AA') ,(2,'BB');
CREATE TABLE #TEST2(ID INT,Column_2 INT);
INSERT INTO #TEST2 VALUES(1,100) ,(2,200) ,(3,300);
--Subquery returned only 1 value.
SELECT *,(SELECT Column_2 FROM #TEST2 WHERE Column_2 = 100) AS 'Number'
FROM #TEST1;
--Subquery returned more than 1 value.
SELECT *,(SELECT Column_2 FROM #TEST2 WHERE Column_2 > 100) AS 'Number'
FROM #TEST1;
So you need to check statements such as: SELECT ...,subquery AS alias
, ISNULL(subquery, '')
in your code,.
Best Regards,
LiHong