select COUNT(*) as '评审专家数'
from (select (select COUNT(distinct container_id) from task_expert where expert_id = e.id and container_type = 1 and `status` in (1,2)) as taskAuditCount,
(select COUNT(distinct container_id)
from task_expert
where expert_id = e.id
and container_type = 2 and `status` in (1,2)) as competitionAuditCount
from experts e where is_delete = '0' and status = 1) tmp
where tmp.taskAuditCount > 0
OR tmp.competitionAuditCount > 0;
select IFNULL(SUM(competitionAuditCount), 0) as '竞赛评审数'
from (select COUNT(distinct container_id) as competitionAuditCount
from task_expert te
join experts e on e.id = te.expert_id and te.container_type = 2 and te.`status` in (1, 2)) tmp;
select IFNULL(SUM(taskAuditCount), 0) as '创客任务评审数'
from (select COUNT(distinct container_id) as taskAuditCount
from task_expert te
join experts e on e.id = te.expert_id and te.container_type = 1 and te.`status` in (1, 2)) tmp;
select * from ( select erl.id, e.id as expert_id,e.user_id, e.expert_name, e.highest_degree, e.graduated_from,
u.nickname as "userNickName",ue.gender as "gender",
e.id_number,images, attachments,
e.major, e.workplace, e.phone,
e.workplace_type, e.expert_email, erl.expert_summary, erl.expert_detail, e.professional_title, e.expert_type,
expert_domain,u.authentication as expertAuth,
e.title_rank, erl.status, e.review_area_one, e.review_area_two, e.review_area_three, e.is_delete, erl.create_by,
erl.create_time,
(select COUNT(*) from task_expert where expert_id = e.id and container_type = 1 and `status` in (1,2)) as taskAuditCount,
(select COUNT(*) from task_expert where expert_id = e.id and container_type = 2 and `status` in (1,2)) as competitionAuditCount,
erl.update_by, erl.update_time,erl.sort_no
from experts e
inner join users u on e.user_id = u.id
inner join user_extensions ue on u.id = ue.user_id
left join expert_resource_library erl on e.id = erl.expert_id
where e.is_delete='0' and e.status=1
) tmp where tmp.taskAuditCount > 0 OR tmp.competitionAuditCount > 0 order by tmp.status;
select e.id,e.expert_name,
(select COUNT(*) from task_expert where expert_id = e.id and container_type = 1) as '参与创客评审数',
(select COUNT(*) from task_expert where expert_id = e.id and container_type = 2) as '参与竞赛评审数'
from experts e
where e.is_delete='0' and e.status=1;