I am creating a front end with VB6 and my database is Sybase. Using DSN I have created some small exe\'s to populate reports in grid. It was working fine.
However if I u
Just so you know the count(seqnum) as Answered is not the correct definition for Aspect UIP inbound calls answered. If you check the field labeled SwitchDispId it could have a 1 or 2 in it which would equate to an abandon call. Hence not a answered call. I do see you are using user_id not null to get answered calls but I just wanted to make you aware of that.
Also you can join the acdcalldetail table to the service table to get names that look more like what the business is used to seeing like this:
SELECT
Service_c
,SUM(CASE WHEN acd.SwitchDispID IN (1,2) THEN 1 ELSE 0 END as Abandons
,SUM(CASE WHEN acd.user_id is not null THEN 1 ELSE 0 END as Answered
FROM acdcalldetail acd
JOIN service s
ON s.service_id = acd.service_id
AND s.sourceid = acd.sourceid
WHERE acd.CallStartDt between '20170501' AND '20170530'
AND s.Service_id NOT IN (37,39,47,51,57,58,96,215,374,375)
GROUP BY
s.Service_c
"select datepart (hh, callstartdt) as Hour, " _
& " count(seqnum) as Anaswered," _
& " sum(case when user_id <> NULL then 1 else 0 end) as answered_calls ," _
& " sum(case when user_id <> NULL and datediff (ss, callstartdt, QueueEndDt) <= 20 then 1 else 0 end) , " _
& " sum(case when user_id = NULL then 1 else 0 end), " _
& " sum(case when user_id <> NULL and datediff (ss, callstartdt, QueueEndDt) <= 20 then 1 else 0 end) / count(seqnum), " _
& " sum(Case when user_id <> NULL then 1 else 0 end ) / count(seqnum) from acdcalldetail " _
& " where callstartdt between '" & fromDt & "' and '" & toDt & "' " _
& " and service_id not in (37,39,47,51,57,58,96,215,374,375) " _
& " group by datepart (hh, callstartdt) " _
& " order by datepart (hh, callstartdt)"