根据一个评价结果的字段来建立一张虚拟表来统计评价结果
座席工号
录音编号
来电号码
评价结果
0001
qww11
88888888
29 评价结果(非常满意1070771、满意1070772、一般1070773、不满意1070774)
满意度调查统计
座席工号
非常满意
满意
一般
不满意
总计
满意度
0001
86
69
14
11
180
93.88%
0002
93
30
6
10
139
92.80%
用sql语句来统计出来一张满意度调查统计表:
select t.agent_id,
sum(case
when t.grade_id = 1070771 then
1
else
0
end) as Vsatisfied,
sum(case
when t.grade_id = 1070772 then
1
else
0
end) as Satisfied,
sum(case
when t.grade_id = 1070773 then
1
else
0
end) as General,
sum(case
when t.grade_id = 1070774 then
1
else
0
end) as Yawp,
count(*) as scount,
(sum(case
when t.grade_id = 1070771 then
1
else
0
end) + sum(case
when t.grade_id = 1070772 then
1
else
0
end) + sum(case
when t.grade_id = 1070773 then
1
else
0
end)) / count(*)*100 ||'%' as satisficing
from tablename t
group by t.agent_id
注: agent_id 坐席工号,grade_id 评价结果