日期:2014-05-17 浏览次数:20582 次
select c.DEPTCODE as name,c.DEPTNAME as name2,ISNULL(AA.number1,0),ISNULL(BB.number2,0),ISNULL(CC.number3,0) from T_JC_DEPARTMENT c
left join
(select COUNT(1) number1,c.DEPTCODE deptcode
from T_JC_CASEBASEINFO c where c.SERVCODE in ( select SERVCODE from T_JC_SERVICEITEM where SERVTYPE='test') group by c.DEPTCODE) AA
on c.DEPTCODE=AA.deptcode
left join
(select COUNT(1) number2,c.DEPTCODE deptcode
from T_JC_CASEBASEINFO c where c.SERVCODE in ( select SERVCODE from T_JC_SERVICEITEM where SERVTYPE='test1') group by c.DEPTCODE) BB
on c.DEPTCODE=BB.deptcode
left join
(select COUNT(1) number3,c.DEPTCODE deptcode
from T_JC_CASEBASEINFO c where c.SERVCODE in ( select SERVCODE from T_JC_SERVICEITEM where SERVTYPE='test2') group by c.DEPTCODE) CC
on c.DEPTCODE=CC.deptcode
where c.DEPTCODE
in('aa','bb')group by c.DEPTCODE,c.DEPTNAME,AA.number1,BB.number2,CC.number3
select COUNT(1) number1,c.DEPTCODE deptcode
from T_JC_CASEBASEINFO c where c.SERVCODE in ( select SERVCODE from T_JC_SERVICEITEM where SERVTYPE='test') group by c.DEPTCODE
select COUNT(1) number1,c.DEPTCODE deptcode
from T_JC_CASEBASEINFO c inner join T_JC_SERVICEITEM d on c.SERVCODE =d.SERVCODE where SERVTYPE='test' group by c.DEPTCODE