有谁懂oracle SQL 的语句 ,麻烦帮我详细解释下这段代码?其中代码中的?是参数可以用数据代替
/*2006年至2010年各省(区、市)国家税务局系统任职培训情况统计表*/selectsubstr(x.dw_dm,2,6)dw_dm,x.dw_jc,x.nd,x.r...
/*2006年至2010年各省(区、市)国家税务局系统任职培训情况统计表*/
select substr(x.dw_dm,2,6) dw_dm,x.dw_jc,x.nd,x.rn,x.jgjc,
sum(y.rzpx_sxqs) rzpx_sxqs,sum(y.rzpx_sxrs) rzpx_sxrs,sum(y.rzpx_sxrts) rzpx_sxrts
from
(Select t.dw_dm, t.dw_jc,b.rn,t.jgjc,c.nd
From dm_dw t,( SELECT '0'||to_char(ROWNUM) rn FROM dual
CONNECT BY ROWNUM <= 2) b,
(Select *
From (Select to_char(rownum) nd From dual Connect By rownum <= ?)
Where nd >= ?) c
Where (t.jgjc = 2 or t.jgjc =23)
and t.dwlb ='1'
and t.yxbz = 1
and t.sjjg = '000'
and t.dw_dm like decode(?,'国家税务局','1','地方税务局','2','全国税务系统',null)||'%'
order by t.jgjc,t.dw_dm) x
left join
(Select a.swjg_dm, c.nd, a.xm_dm,Sum(a.rzpx_sxqs) rzpx_sxqs, Sum(a.rzpx_sxrs) rzpx_sxrs, sum(a.rzpx_sxrts) rzpx_sxrts
From kp_kprw_snpxqk a, kp_kprw c
Where a.kprw_dm = c.kprw_dm
And a.xm_dm in ( '01','02' ) --省内培训合计
And c.nd Between ? And ?
and c.kprw_zt = '3'
Group By a.swjg_dm,c.nd,a.xm_dm
) y
on x.dw_dm = y.swjg_dm and x.rn =y.xm_dm and x.nd = y.nd
group by substr(x.dw_dm,2,6), x.dw_jc, x.nd,x.rn,x.jgjc
order by x.jgjc,substr(x.dw_dm,2,6),x.nd,x.rn 展开
select substr(x.dw_dm,2,6) dw_dm,x.dw_jc,x.nd,x.rn,x.jgjc,
sum(y.rzpx_sxqs) rzpx_sxqs,sum(y.rzpx_sxrs) rzpx_sxrs,sum(y.rzpx_sxrts) rzpx_sxrts
from
(Select t.dw_dm, t.dw_jc,b.rn,t.jgjc,c.nd
From dm_dw t,( SELECT '0'||to_char(ROWNUM) rn FROM dual
CONNECT BY ROWNUM <= 2) b,
(Select *
From (Select to_char(rownum) nd From dual Connect By rownum <= ?)
Where nd >= ?) c
Where (t.jgjc = 2 or t.jgjc =23)
and t.dwlb ='1'
and t.yxbz = 1
and t.sjjg = '000'
and t.dw_dm like decode(?,'国家税务局','1','地方税务局','2','全国税务系统',null)||'%'
order by t.jgjc,t.dw_dm) x
left join
(Select a.swjg_dm, c.nd, a.xm_dm,Sum(a.rzpx_sxqs) rzpx_sxqs, Sum(a.rzpx_sxrs) rzpx_sxrs, sum(a.rzpx_sxrts) rzpx_sxrts
From kp_kprw_snpxqk a, kp_kprw c
Where a.kprw_dm = c.kprw_dm
And a.xm_dm in ( '01','02' ) --省内培训合计
And c.nd Between ? And ?
and c.kprw_zt = '3'
Group By a.swjg_dm,c.nd,a.xm_dm
) y
on x.dw_dm = y.swjg_dm and x.rn =y.xm_dm and x.nd = y.nd
group by substr(x.dw_dm,2,6), x.dw_jc, x.nd,x.rn,x.jgjc
order by x.jgjc,substr(x.dw_dm,2,6),x.nd,x.rn 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询