如图,我有一个存储过程(示例),我想要(SELECT MAX(SJ) AS SJ FROM TEST10086)这个值如果 <> '2023',就只展示SELECT * FROM TEST3 (不用union TEST1/TEST2 )该怎么修改,求大神解惑 CREATE OR REPLACE PROCEDURE P_TEST AS BEGIN DELETE FROM TEST WHERE SJ = (SELECT MAX(SJ) AS SJ FROM TEST10086); INSERT INTO TEST WITH TEST1 AS ( SELECT ID,DJ FROM A), TEST2 AS ( SELECT ID,DJ FROM B), TEST3 AS ( SELECT ID,DJ FROM C), HZ AS ( SELECT * FROM TEST1 UNION ALL SELECT * FROM TEST2 UNION ALL SELECT * FROM TEST3 ) SELECT ID,SUM(DJ) FROM HZ GROUP BY ID; END ; |