Report to capture Hook Count without any call - Query validation

Version 1
    This document was generated from CDN thread

    Created by: Sivakarthikeyan Velayutham on 23-09-2011 12:04:47 AM
    Hi,
       We have to requirement from our customer to capture agents who go off hook without any inbound calls (just to make themself busy and avoid calls).
    I would like my SQL to get validated from an expert in this forum.
     
    Note: 1) Inbound only contact center
      2) All inbound calls are trans routed
     
    select A.EnterpriseName AgentName, T.AgentPeripheralNumber as AgentLoginID, count(*) Hook_Count
    from Termination_Call_Detail T, cicm2_awdb..Agent A where
    A.PeripheralNumber=T.AgentPeripheralNumber and
    DateTime between '2011-09-22 23:30:00' and '2011-09-23 01:00:00' 
    and DigitsDialed is null and len (ANI) = 6 and
    DNIS is NULL and PeripheralCallType='10' and RouterCallKey='0' and ANI like '55%' and (CallDisposition='7' or CallDisposition='4')
    Group by A.EnterpriseName, T.AgentPeripheralNumber
    order by count(*) desc


    Thanks
    Siva