Dybest set forsøger du at gemme en streng, der repræsenterer en dato i et tidsstempelfelt. Hvis du erstatter:
TO_CHAR(TS, 'DD-MON-YYYY HH AM')
af
TRUNC(TS, 'hh24')
alle 4 steder burde det virke.
INSERT INTO ENROLLMENTS (DATE,PARTNER_NAME,ENROLLMENTS)
SELECT TRUNC(TS, 'hh24') AS DATE, mrch_bnft_cd, COUNT(*)
FROM ENROLLMENTS
WHERE TS > trunc(sysdate-1/24, 'HH') + 5/24
AND TS < trunc(sysdate, 'HH') + 5/24
GROUP BY TRUNC(TS, 'hh24'), mrch
ORDER BY TRUNC(TS, 'hh24'), mrch_bnft