18291776824(提问者)select * from (
With temp As (
Select qxmc,decode(djxl,\'GF\',\'房屋登记\',\'G0\',\'土地登记\',\'J0\',\'土地登记\',\'Z0\',\'土地登记\') djxl,djdlmc,ywmc,fwzl_mc,
decode(sactivityname,\'窗口受理\',\'收件\',\'缮证登簿\',\'缮证\',\'打证\',\'缮证\',\'注销登簿\',\'缮证\',sactivityname) sactivityname,
count(sdata1) numb From sa_task a Inner Join t_ywslb b
On (a.sdata1 = b.fbizrecid)
where ywdm in (\'GF100\',\'GF200\',\'GF300\',\'GF400\',\'GF500\')
and b.slsj >= TO_DATE(\'${starttime}\', \'yyyy-MM-dd\')
And b.slsj < TO_DATE(\'${endtime}\', \'yyyy-MM-dd\')
${if(len(qxmc)==0,\"\",\"and qxmc=\'\"+qxmc+\"\'\")}
${if(len(fwzl_mc)==0,\"\",\"and fwzl_mc=\'\"+fwzl_mc+\"\'\")}
${if(len(djdlmc)==0,\"\",\"and djdlmc=\'\"+djdlmc+\"\'\")}
${if(len(ywmc)==0,\"\",\"and ywmc=\'\"+ywmc+\"\'\")}
And a.sactivityname In(\'收件\',\'窗口受理\',\'初审\',\'复审\',\'缮证\',\'缮证登簿\',\'打证\')
And a.sstatusid = \'tesFinished\' And sexecutorfid Is Not Null And ssourceid Is Null
Group By qxmc,
decode(djxl,\'GF\',\'房屋登记\',\'G0\',\'土地登记\',\'J0\',\'土地登记\',\'Z0\',\'土地登记\'),
djdlmc,b.ywmc,fwzl_mc,
decode(sactivityname,\'窗口受理\',\'收件\',\'缮证登簿\',\'缮证\',\'打证\',\'缮证\',\'注销登簿\',\'缮证\',sactivityname)
)
Select a.qxmc,a.djxl,a.djdlmc,a.ywmc,a.fwzl_mc,b.numb As 收件量, c.numb As 初审量, d.numb As 复审量, e.numb As 缮证量
From (Select qxmc,djxl,djdlmc,ywmc,fwzl_mc From temp Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc) a
Left Join
(Select qxmc,djxl,djdlmc,ywmc,fwzl_mc, Sum(numb) numb From temp Where sactivityname= \'收件\' Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc) b
On a.qxmc = b.qxmc And a.fwzl_mc = b.fwzl_mc
Left Join
(Select qxmc,djxl,djdlmc,ywmc,fwzl_mc, Sum(numb) numb From temp Where sactivityname= \'初审\' Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc) c
On a.qxmc = c.qxmc And a.fwzl_mc = c.fwzl_mc
Left Join
(Select qxmc,djxl,djdlmc,ywmc,fwzl_mc, Sum(numb) numb From temp Where sactivityname= \'复审\' Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc) d
On a.qxmc = d.qxmc And a.fwzl_mc = d.fwzl_mc
Left Join
(Select qxmc,djxl,djdlmc,ywmc,fwzl_mc, Sum(numb) numb From temp Where sactivityname= \'缮证\' Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc ) e
On a.qxmc = e.qxmc And a.fwzl_mc = e.fwzl_mc
Order By a.qxmc ,a.djdlmc,a.fwzl_mc ) m1
UNION ALL
----2.土地登记业务
select * from (
With temp As (
Select qxmc,decode(djxl,\'GF\',\'房屋登记\',\'G0\',\'土地登记\',\'J0\',\'土地登记\',\'Z0\',\'土地登记\') djxl,djdlmc,ywmc,fwzl_mc,
decode(sactivityname,\'窗口受理\',\'收件\',\'缮证登簿\',\'缮证\',\'打证\',\'缮证\',\'注销登簿\',\'缮证\',sactivityname) sactivityname,
count(sdata1) numb From sa_task a Inner Join t_ywslb b
On (a.sdata1 = b.fbizrecid)
where ywdm in (\'G0100\',\'G0200\',\'G0300\',\'G0400\',\'G0500\')
and b.slsj >= TO_DATE(\'${starttime}\', \'yyyy-MM-dd\')
And b.slsj < TO_DATE(\'${endtime}\', \'yyyy-MM-dd\')
${if(len(qxmc)==0,\"\",\"and qxmc=\'\"+qxmc+\"\'\")}
${if(len(fwzl_mc)==0,\"\",\"and fwzl_mc=\'\"+fwzl_mc+\"\'\")}
${if(len(djdlmc)==0,\"\",\"and djdlmc=\'\"+djdlmc+\"\'\")}
${if(len(ywmc)==0,\"\",\"and ywmc=\'\"+ywmc+\"\'\")}
And a.sactivityname In(\'收件\',\'窗口受理\',\'初审\',\'复审\',\'缮证\',\'缮证登簿\',\'打证\')
And a.sstatusid = \'tesFinished\' And sexecutorfid Is Not Null And ssourceid Is Null
Group By qxmc,
decode(djxl,\'GF\',\'房屋登记\',\'G0\',\'土地登记\',\'J0\',\'土地登记\',\'Z0\',\'土地登记\'),
djxl,djdlmc,b.ywmc,fwzl_mc,
decode(sactivityname,\'窗口受理\',\'收件\',\'缮证登簿\',\'缮证\',\'打证\',\'缮证\',\'注销登簿\',\'缮证\',sactivityname)
)
Select a.qxmc,a.djxl,a.djdlmc,a.ywmc,a.fwzl_mc,b.numb As 收件量, c.numb As 初审量, d.numb As 复审量, e.numb As 缮证量
From (Select qxmc,djxl,djdlmc,ywmc,fwzl_mc From temp Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc) a
Left Join
(Select qxmc,djxl,djdlmc,ywmc,fwzl_mc, Sum(numb) numb From temp Where sactivityname= \'收件\' Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc) b
On a.qxmc = b.qxmc
Left Join
(Select qxmc,djxl,djdlmc,ywmc,fwzl_mc, Sum(numb) numb From temp Where sactivityname= \'初审\' Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc) c
On a.qxmc = c.qxmc
Left Join
(Select qxmc,djxl,djdlmc,ywmc,fwzl_mc, Sum(numb) numb From temp Where sactivityname= \'复审\' Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc) d
On a.qxmc = d.qxmc
Left Join
(Select qxmc,djxl,djdlmc,ywmc,fwzl_mc, Sum(numb) numb From temp Where sactivityname= \'缮证\' Group By qxmc,djxl,djdlmc,ywmc,fwzl_mc ) e
On a.qxmc = e.qxmc
Order By a.qxmc,a.djdlmc,a.fwzl_mc ) m2