22,209
社区成员
发帖
与我相关
我的任务
分享
select
sum(case when b.cstatus='正式' then 1 else 0 end) as 正式,
sum(case when b.cstatus='试用' then 1 else 0 end) as 试用,
sum(case when b.cstatus='实习' then 1 else 0 end) as 实习,
sum(case when b.cstatus='临时' then 1 else 0 end) as 临时,
sum(case when b.cstatus='外聘' then 1 else 0 end) as 外聘
from ht_empy_dept a,ht_empy b
where b.dleave IS NULL and b.dcome<'2008-01-01' and a.corg='100001' and a.cpsnno =b.cpsnno
惭愧,我上面的错了,晕!!!
-----------
select
正式=sum(case when ht_empy.cstatus='正式' then 1 else 0 end),
试用=sum(case when ht_empy.cstatus='试用' then 1 else 0 end),
实习=sum(case when ht_empy.cstatus='实习' then 1 else 0 end),
临时=sum(case when ht_empy.cstatus='临时' then 1 else 0 end),
外聘=sum(case when ht_empy.cstatus='外聘' then 1 else 0 end),
from ht_empy_dept where cpsnno in(select cpsnno from ht_empy
where ht_empy.dleave IS NULL and dcome <'2008-01-01') and corg='100001'
select
sum(case when b.cstatus='正式' then 1 else 0 end) as 正式,
sum(case when b.cstatus='试用' then 1 else 0 end) as 试用,
sum(case when b.cstatus='实习' then 1 else 0 end) as 实习,
sum(case when b.cstatus='临时' then 1 else 0 end) as 临时,
sum(case when b.cstatus='外聘' then 1 else 0 end) as 外聘
from
ht_empy_dept a,
ht_empy b
where
a.cpsnno=b.cpsnno
and
a.corg='100001'
and
b.dleave IS NULL
and
b.dcome<'2008-01-01'
select
正式=count(case when ht_empy.cstatus='正式' then 1 else 0 end),
试用=count(case when ht_empy.cstatus='试用' then 1 else 0 end),
.
.
.
.
from ht_empy_dept where cpsnno in(select cpsnno from ht_empy
where ht_empy.dleave IS NULL and dcome <'2008-01-01') and corg='100001'