If I understood you correctly, then below solution would solve your problem.
SELECT a.blank8, b.rownum
(
SELECT
-- add PK ,
CAST(CAST(t.blank8 AS FORMAT'9(6)') AS CHAR(8))
FROM ji_core_v.keepH T
WHERE NOT EXISTS(SELECT *
FROM SYS_CALENDAR.CALENDAR C
WHERE CAST(CAST(t.blank8 AS FORMAT'9(6)') AS CHAR(8)) = C.CALENDAR_DATE (FORMAT 'YYYYMMDD' ) (CHAR(8))
)
) a
INNER JOIN
(
SELECT
-- add PK,
CAST(CAST(t.blank8 AS FORMAT'9(6)') AS CHAR(8)),
ROW_NUMBER() OVER (ORDER BY /*whatever you want to order by*/) rownum
FROM ji_core_v.keepH T
) b
ON a.blank8 = b.blank8
AND /*a.PK = b.PK*/
↧