Skip to content

公司每月的触达率和接通率,数据库导出sql如下 ​

sql
SELECT
    monthValue as '月份',
    call_data as '公司编码',
    (select org.org_name from tb_sys_organization org where org.branch_id = t.call_data and org.is_branch = 1 and org.delete_flag = 0 LIMIT 1) as '公司名称',
    COUNT(1) as '总数',
    SUM(call_result) as '接通数',
    ROUND(SUM(call_result) / COUNT(1), 8) as '接通比例',
    CONCAT(
        -- 去掉末尾 0 
            TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM CAST(
                -- 计算百分比,并且四舍五入设置精确度
                    ROUND(SUM(call_result) * 100 / COUNT(1), 2)
                AS CHAR))),
            '%') AS '接通百分比',
    SUM(cdlx) as '触达数',
    ROUND(SUM(cdlx) / COUNT(1), 8) as '触达比例',
    CONCAT(
        -- 去掉末尾 0 
            TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM CAST(
                -- 计算百分比,并且四舍五入设置精确度
                    ROUND(SUM(cdlx) * 100 / COUNT(1), 2)
                AS CHAR))),
            '%') AS '触达百分比'
FROM (
    SELECT
        -- 月份
        DATE_FORMAT(t1.c_start_time, '%Y-%m') as monthValue,
        -- 公司
        t1.call_data,
        -- 是否接通
        t1.call_result,
        -- 是否触达
        -- IF(t1.call_result != 1 and t1.ringsec = 0, '未触达', '已触达') as '触达类型'
        IF(t1.call_result != 1 and t1.ringsec = 0, 0, 1) as cdlx
    FROM tb_call_history t1
    where 1=1
        and t1.call_data is not NULL
        -- 5、6、7、8这四个月的;每个月,每个公司的触达率和接通率
        and t1.c_start_time >= '2026-05-01-00:00:00'
        and t1.c_start_time < '2026-09-01-00:00:00'
    ) t
GROUP BY monthValue,call_data
ORDER BY monthValue,call_data

页脚:版权前显示的信息