根据一个评价结果的字段来创建一张虚拟表来统计评价结果

座席工号 录音编号 来电号码 评价结果
0001 qww11 88888888 29
评价结果(很是满意107077一、满意1070772、通常1070773、不满意1070774)

满意度调查统计
座席工号 很是满意 满意 通常 不满意 总计 满意度
0001 86 69 14 11 180 93.88%
0002 93 30 6 10 139 92.80%

用sql语句来统计出来一张满意度调查统计表: 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
spa

注: agent_id 坐席工号,grade_id 评价结果
相关文章
相关标签/搜索