以下は私のSQLクエリです
BEGIN TRAN
DECLARE @PRE_CD INT = (SELECT ISNULL(MAX(PRE_CD), 0) FROM TBL_MAIN)
INSERT INTO TBL_MAIN
(PRE_CD,
PRE_DESC,
PRE_REF_CD)
SELECT ROW_NUMBER() OVER (ORDER BY PRESENTATION) + @PRE_CD,
PRESENTATION,
3
FROM (SELECT DISTINCT PRESENTATION
FROM Temp_Data
WHERE PRESENTATION NOT IN (SELECT PRE_DESC
FROM TBL_MAIN)) T
COMMIT;
このクエリを実行すると、エラーが発生します
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.