SELECT A.MCF_CHAT_ID , R.MCFREN_LOG_RTENT , 0 , 0 , 0 , 0 , COUNT(*) BUDDY_INVITE , A.OPRID , O.PERSON_ID , A.DTTM_STAMP , B.DTTM_STAMP FROM PS_MCFCHATLOG A , PS_MCFCHATLOG B , PSMCFRENMAP R , PSOPRALIAS O WHERE A. MCF_CHAT_ACTION = 'Accept' AND A.OPRID = O.OPRID AND B.MCF_CHAT_ACTION = 'End' AND A.MCF_CHAT_ID = B.MCF_CHAT_ID AND A.MCF_CHAT_ID IN ( SELECT DISTINCT B.MCF_CHAT_ID FROM PS_MCFCHATLOG B , PS_MCFCHATLOG C WHERE C.MCF_CHAT_ID = B.MCF_CHAT_ID AND B.MCF_CHAT_ACTION = 'Accept' AND B.OPRID <> C.OPRID AND B.MCFUQTASKNUM = C.MCFUQTASKNUM) AND R.MCFREN_PHYS_RTENT IN ( SELECT DISTINCT B.MCFREN_PHYS_RTENT FROM PSMCFRENMAP B , PS_MCFCHATLOG C , PS_MCFCHATLOG D , PS_MCFCHATLOG E WHERE B.MCFREN_PHYS_RTENT = C.MCFUQQUEUEID AND C.MCF_CHAT_ID = D.MCF_CHAT_ID AND C.MCF_CHAT_ID = E.MCF_CHAT_ID AND C.MCF_CHAT_ACTION = 'InitChat' AND D.MCFUQTASKNUM <> 'UNDEFINED' AND E.MCFUQTASKNUM <> 'UNDEFINED' AND D.MCF_CHAT_ACTION = 'Accept' AND E.MCF_CHAT_ACTION = 'Accept' AND D.MCFUQTASKNUM = E.MCFUQTASKNUM AND D.DTTM_STAMP <> E.DTTM_STAMP AND D.OPRID <> E.OPRID) GROUP BY A.MCF_CHAT_ID, A.OPRID, O.PERSON_ID, A.DTTM_STAMP, B.DTTM_STAMP, R.MCFREN_LOG_RTENT
|