Appearance
查询每个公司的默认坐席
sql
SELECT
branch_id as '公司编码',
(select org.org_name from tb_sys_organization org where org.branch_id = t.branch_id and org.is_branch = 1 and org.delete_flag = 0 LIMIT 1) as '公司名称',
hr_staff_id,
real_name as '名称',
username as '坐席账号'
FROM tb_call_employee t
WHERE 1=1
and branch_id is not null
and hr_staff_id is not NULL
-- 默认标识
and default_agent_flag = 1查没有默认坐席的公司
sql
SELECT branch_id,COUNT(IF(default_agent_flag = 1,1,null))
from tb_call_employee
WHERE 1=1
and branch_id is not null
and hr_staff_id is not NULL
GROUP BY branch_id
-- 默认标识的数据量为 0
HAVING COUNT(IF(default_agent_flag = 1,1,null)) = 0查这几个没有配默认坐席的公司的具体数据
sql
SELECT
branch_id as '公司编码',
(select org.org_name from tb_sys_organization org where org.branch_id = t.branch_id and org.is_branch = 1 and org.delete_flag = 0 LIMIT 1) as '公司名称',
hr_staff_id,
real_name as '名称',
username as '坐席账号',
default_agent_flag
FROM tb_call_employee t
WHERE 1=1
and branch_id is not null
and hr_staff_id is not NULL
AND branch_id in (
-- 查没有默认坐席的公司
'FD4',
'FHJ',
'FK5',
'FM9',
'ZZZ'
)
ORDER BY branch_id,hr_staff_id