SELECT A.OPRID , 0 , 0 , 0 , 0 , 0 , 0 , 0 , B.SLA_EXT_BASE_DTTM , A.ROW_ADDED_DTTM , COUNT(*) OVER (PARTITION BY OPRID ,TO_DATE(TO_CHAR(A.ROW_ADDED_DTTM ,'YYYY-MM-DD') ,'YYYY-MM-DD')) , COUNT(*) OVER(PARTITION BY A.OPRID ,SUBSTR(A.ROW_ADDED_DTTM ,1 ,10) || ' [' || CASE WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '01' THEN '01am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '02' THEN '02am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '03' THEN '03am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '04' THEN '04am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '05' THEN '05am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '06' THEN '06am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '07' THEN '07am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '08' THEN '08am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '09' THEN '09am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '10' THEN '10am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '11' THEN '11am' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '12' THEN '12pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '13' THEN '01pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '14' THEN '02pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '15' THEN '03pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '16' THEN '04pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '17' THEN '05pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '18' THEN '06pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '19' THEN '07pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '20' THEN '08pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '21' THEN '09pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '22' THEN '10pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '23' THEN '11pm' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '00' THEN '12am' END || '-' || CASE WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '12' THEN '01 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '11' THEN '12 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '10' THEN '11 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '09' THEN '10 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '08' THEN '09 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '07' THEN '08 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '06' THEN '07 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '05' THEN '06 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '04' THEN '05 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '03' THEN '04 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '02' THEN '03 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '01' THEN '02 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '00' THEN '01 am]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '13' THEN '02 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '14' THEN '03 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '15' THEN '04 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '16' THEN '05 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '17' THEN '06 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '18' THEN '07 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '19' THEN '08 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '20' THEN '09 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '21' THEN '10 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '22' THEN '11 pm]' WHEN SUBSTR(A.ROW_ADDED_DTTM ,12 ,2) = '23' THEN '12 am]' END) , COUNT(*) OVER (PARTITION BY A.OPRID ,TO_CHAR(CAST((A.ROW_ADDED_DTTM) AS TIMESTAMP) ,'Month,YYYY')) , COUNT(*) OVER (PARTITION BY A.OPRID ,((TO_DATE(TO_DATE(TO_CHAR(A.ROW_ADDED_DTTM ,'YYYY-MM-DD') ,'YYYY-MM-DD') ,'YYYY-MM-DD')) + ((MOD((((TO_DATE(TO_DATE(TO_CHAR(A.ROW_ADDED_DTTM ,'YYYY-MM-DD') ,'YYYY-MM-DD') ,'YYYY-MM-DD')) - (TO_DATE(1900 || '-' || 01 || '-' || 01 , 'YYYY-MM-DD')))) ,7)*-1)))) FROM PS_RB_AGNT_RESP_VW A , PS_RB_IN_EMAIL B WHERE B.INTERACTION_ID = A.ROOT_INTER_ID GROUP BY A.OPRID,SLA_EXT_BASE_DTTM,A.ROW_ADDED_DTTM
|