select a.jobsort,a.begin_num,b.in_num,c.out_num
from(select count(*) begin_num,jobsort //月初人数,工种
from employees
where status <> 'T'
and start_date < :as_date_s
group by jobsort) a
left join (select count(*) in_num ,jobsort//本月入职人数,工种
from employees
where status = 'A'
and start_date between :as_date_s and :as_date_e
group by jobsort ) b
on a.jobsort = b.jobsort
left join
(select count(*) out_num,jobsort //本月离职人数,工种
from employees
where Status = 'T'
and start_date between :as_date_s and :as_date_e
group by jobsort)c
on a.jobsort = c.jobsort
或者select a.jobsort,a.begin_num,b.in_num,c.out_num
from(select count(*) begin_num,jobsort //月初人数,工种
from employees
where status <> 'T'
and start_date < :as_date_s
group by jobsort) a
right join (select count(*) in_num ,jobsort//本月入职人数,工种
from employees
where status = 'A'
and start_date between :as_date_s and :as_date_e
group by jobsort ) b
on a.jobsort = b.jobsort
right join
(select count(*) out_num,jobsort //本月离职人数,工种
from employees
where Status = 'T'
and start_date between :as_date_s and :as_date_e
group by jobsort)c
on a.jobsort = c.jobsort
from(select count(*) begin_num,jobsort //月初人数,工种
from employees
where status <> 'T'
and start_date < :as_date_s
group by jobsort) a
left join (select count(*) in_num ,jobsort//本月入职人数,工种
from employees
where status = 'A'
and start_date between :as_date_s and :as_date_e
group by jobsort ) b
on a.jobsort = b.jobsort
left join
(select count(*) out_num,jobsort //本月离职人数,工种
from employees
where Status = 'T'
and start_date between :as_date_s and :as_date_e
group by jobsort)c
on a.jobsort = c.jobsort
或者select a.jobsort,a.begin_num,b.in_num,c.out_num
from(select count(*) begin_num,jobsort //月初人数,工种
from employees
where status <> 'T'
and start_date < :as_date_s
group by jobsort) a
right join (select count(*) in_num ,jobsort//本月入职人数,工种
from employees
where status = 'A'
and start_date between :as_date_s and :as_date_e
group by jobsort ) b
on a.jobsort = b.jobsort
right join
(select count(*) out_num,jobsort //本月离职人数,工种
from employees
where Status = 'T'
and start_date between :as_date_s and :as_date_e
group by jobsort)c
on a.jobsort = c.jobsort
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货