0
WITH CTE AS
(SELECT
F.PARTITION_KEY,
(LAST_DAY(TO_DATE((PARTITION_KEY)||'01','YYYYMMDD'))) AS VALID_DATE,
F.EMP_NUM,
F.EMP_KEY,
D.EMP_ENTERED_DATE
FROM F_EMP_ERROR, D_EMP D
WHERE
F.EMP_NUM = D.EMP_NUM
AND F.PARTITION_KEY = 201603
and d.CONTRACT_PERIOD = 'Y')
SELECT COUNT(DISTINCT EMP_NUM) FROM CTE WHERE EMP_ENTERED_DATE > VALID_DATE;
我的查詢工作正常,如果我硬編碼一個特定的月份。如何將它轉換爲一種方式,當我輸入年,它應該返回記錄數在那一年的所有月份。PL/SQL程序動態傳遞值