SELECT A.SPLIT,
SUM(CASE WHEN answer_time IS NOT NULL AND A.ent_split IS NOT NULL AND call_type NOT LIKE 'PBX%' THEN 1 ELSE 0 END) AS CH,
SUM(CASE WHEN answer_time IS NOT NULL AND A.ent_split IS NOT NULL AND call_type NOT LIKE 'PBX%' THEN 1 ELSE 0 END) + SUM(CASE WHEN abandon_time IS NOT NULL AND answer_time IS NULL THEN 1 ELSE 0 END) AS CO,
SUM(CASE WHEN answer_time IS NOT NULL AND A.ent_split IS NOT NULL AND call_type NOT LIKE 'PBX%' THEN 1 ELSE 1 END) AS AHT
FROM reporting_call_matrix AS A WITH (NOLOCK)
WHERE A.CALENDAR_DATE >= '10/01/2015' AND A.CALENDAR_DATE <= '9/30/2016' AND A.SPLIT IN (9,26,23,43,48,33,56,70,71,72,74,50) AND ( A.ent_split IS NOT NULL)
Group BY A.SPLIT
Heres是我的代码提出的一些数据。
Split CH CO AHT
9 957157 1156319 1156461
答案 0 :(得分:0)
你是说这个?
SELECT A.SPLIT, A.CALENDAR_DATE,
SUM(CASE WHEN answer_time IS NOT NULL AND A.ent_split IS NOT NULL AND call_type NOT LIKE 'PBX%' THEN 1 ELSE 0 END) AS CH,
SUM(CASE WHEN answer_time IS NOT NULL AND A.ent_split IS NOT NULL AND call_type NOT LIKE 'PBX%' THEN 1 ELSE 0 END) + SUM(CASE WHEN abandon_time IS NOT NULL AND answer_time IS NULL THEN 1 ELSE 0 END) AS CO,
SUM(CASE WHEN answer_time IS NOT NULL AND A.ent_split IS NOT NULL AND call_type NOT LIKE 'PBX%' THEN 1 ELSE 1 END) AS AHT
FROM reporting_call_matrix AS A WITH (NOLOCK)
WHERE A.CALENDAR_DATE >= '10/01/2015' AND A.CALENDAR_DATE <= '9/30/2016' AND A.SPLIT IN (9,26,23,43,48,33,56,70,71,72,74,50) AND ( A.ent_split IS NOT NULL)
Group BY A.SPLIT, A.CALENDAR_DATE