---dt10
SELECT nvl(A.SL,0)+nvl(B.SL,0) AS SL,C.BM AS BM FROM (select SUM(T1.N05) as sl, DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtd_ZD_tb t1,jlqj_wtd_tb t
where 1=1 AND T1.U_STATE >2
and t.wtd_bh=t1.wtd_bh
and t1.n02 IN (1,4) AND T1.U_STATE IS NOT NULL
GROUP BY DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)) A,(select count(*) as sl,DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtqj_tb t1 ,jlqj_ydzjjh_tb t,jlqj_wtd_zd_tb wtzd
where 1=1 and t.n02 =1
and wtzd.u_state>2 and t.ydzjjh_bm =t1.d02
and t1.zd_bm = wtzd.zd_bm
GROUP BY DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3))B,(select distinct bm from (select SUM(T1.N05) as sl, DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtd_ZD_tb t1,jlqj_wtd_tb t
where 1=1 AND T1.U_STATE >2and t.wtd_bh=t1.wtd_bh
and t1.n02 IN (1,4) AND T1.U_STATE IS NOT NULL
GROUP BY DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3) unionselect count(*) as sl,DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtqj_tb t1 ,jlqj_ydzjjh_tb t,jlqj_wtd_zd_tb wtzd
where 1=1 and t.n02 =1
and wtzd.u_state>2
and t.ydzjjh_bm =t1.d02
and t1.zd_bm = wtzd.zd_bm
GROUP BY DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3))) Cwhere A.BM (+)=C.BM and B.BM (+)=C.BM) xfsl,(
---dt11
SELECT nvl(A.SL,0)+nvl(B.SL,0) AS SL,C.BM AS BM FROM
(select SUM(T1.N05) as sl, DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtd_ZD_tb t1,jlqj_wtd_tb t
where 1=1 AND T1.U_STATE >3
and t.wtd_bh=t1.wtd_bh
and t1.n02 IN (1,4) AND T1.U_STATE IS NOT NULL
GROUP BY DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)) A,
(select count(*) as sl,DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtqj_tb t1 ,jlqj_ydzjjh_tb t,jlqj_wtd_zd_tb wtzd
where 1=1 and t.n02 =1
and wtzd.u_state>3 and t.ydzjjh_bm =t1.d02
and t1.zd_bm = wtzd.zd_bm
GROUP BY DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3))B,(select distinct bm from (select SUM(T1.N05) as sl, DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtd_ZD_tb t1,jlqj_wtd_tb t
where 1=1 AND T1.U_STATE >3and t.wtd_bh=t1.wtd_bh
and t1.n02 IN (1,4) AND T1.U_STATE IS NOT NULL
GROUP BY DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3) unionselect count(*) as sl,DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtqj_tb t1 ,jlqj_ydzjjh_tb t,jlqj_wtd_zd_tb wtzd
where 1=1 and t.n02 =1
and wtzd.u_state>3
and t.ydzjjh_bm =t1.d02
and t1.zd_bm = wtzd.zd_bm
GROUP BY DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)) Cwhere A.BM (+)=C.BM and B.BM (+)=C.BM这是两个查询后的语句dt10,dt11,他们的唯一差别在于标记的位置u_state
我想要的结构是select dt10.sl,dt11.sl from dt10,dt11这样的,但是 如果我把dt10,dt11都按上边的写 那太长了,
这个怎么改能短一些?
SELECT nvl(A.SL,0)+nvl(B.SL,0) AS SL,C.BM AS BM FROM (select SUM(T1.N05) as sl, DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtd_ZD_tb t1,jlqj_wtd_tb t
where 1=1 AND T1.U_STATE >2
and t.wtd_bh=t1.wtd_bh
and t1.n02 IN (1,4) AND T1.U_STATE IS NOT NULL
GROUP BY DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)) A,(select count(*) as sl,DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtqj_tb t1 ,jlqj_ydzjjh_tb t,jlqj_wtd_zd_tb wtzd
where 1=1 and t.n02 =1
and wtzd.u_state>2 and t.ydzjjh_bm =t1.d02
and t1.zd_bm = wtzd.zd_bm
GROUP BY DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3))B,(select distinct bm from (select SUM(T1.N05) as sl, DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtd_ZD_tb t1,jlqj_wtd_tb t
where 1=1 AND T1.U_STATE >2and t.wtd_bh=t1.wtd_bh
and t1.n02 IN (1,4) AND T1.U_STATE IS NOT NULL
GROUP BY DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3) unionselect count(*) as sl,DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtqj_tb t1 ,jlqj_ydzjjh_tb t,jlqj_wtd_zd_tb wtzd
where 1=1 and t.n02 =1
and wtzd.u_state>2
and t.ydzjjh_bm =t1.d02
and t1.zd_bm = wtzd.zd_bm
GROUP BY DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3))) Cwhere A.BM (+)=C.BM and B.BM (+)=C.BM) xfsl,(
---dt11
SELECT nvl(A.SL,0)+nvl(B.SL,0) AS SL,C.BM AS BM FROM
(select SUM(T1.N05) as sl, DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtd_ZD_tb t1,jlqj_wtd_tb t
where 1=1 AND T1.U_STATE >3
and t.wtd_bh=t1.wtd_bh
and t1.n02 IN (1,4) AND T1.U_STATE IS NOT NULL
GROUP BY DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)) A,
(select count(*) as sl,DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtqj_tb t1 ,jlqj_ydzjjh_tb t,jlqj_wtd_zd_tb wtzd
where 1=1 and t.n02 =1
and wtzd.u_state>3 and t.ydzjjh_bm =t1.d02
and t1.zd_bm = wtzd.zd_bm
GROUP BY DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3))B,(select distinct bm from (select SUM(T1.N05) as sl, DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtd_ZD_tb t1,jlqj_wtd_tb t
where 1=1 AND T1.U_STATE >3and t.wtd_bh=t1.wtd_bh
and t1.n02 IN (1,4) AND T1.U_STATE IS NOT NULL
GROUP BY DECODE(t1.N04,23,1,1,1,21,1,25,2,26,3) unionselect count(*) as sl,DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)as bm from jlqj_wtqj_tb t1 ,jlqj_ydzjjh_tb t,jlqj_wtd_zd_tb wtzd
where 1=1 and t.n02 =1
and wtzd.u_state>3
and t.ydzjjh_bm =t1.d02
and t1.zd_bm = wtzd.zd_bm
GROUP BY DECODE(wtzd.N04,23,1,1,1,21,1,25,2,26,3)) Cwhere A.BM (+)=C.BM and B.BM (+)=C.BM这是两个查询后的语句dt10,dt11,他们的唯一差别在于标记的位置u_state
我想要的结构是select dt10.sl,dt11.sl from dt10,dt11这样的,但是 如果我把dt10,dt11都按上边的写 那太长了,
这个怎么改能短一些?
解决方案 »
- .net中 给自己创建的 datatable 循环赋值
- 谁能推荐一个最容易学的.NET 开发框架?
- 关于js字符串连接
- freetextbox怎样可以在文件上传窗口中看见WORD文件?
- ASP.NET(VB.NET) datagrid控件批量操作 【 顶 】
- 我编的textbox为什么不能识别中文啊?郁闷~~
- 为什么网页上有错误!大家快帮忙啊,急死我了!!!
- 如何为datagrid 的每一个列增加一个click事件 当单击执行某个函数
- 显示记录的前N个字
- 愁了!日语一点不会,如何做日语项目啊?
- 急:怎么取出数据表某一记录的字段返回到Textbox中......(c# asp.net2.0 Oracle)[
- gridview 选中单击行,触发事件,读取该行数据,并显示在本页面的textbox控件中
select sl from a
where u_state>3
union
select sl from b
where u_state>3
union
select sl from c
where u_state>3
----dt11
select sl from a
where u_state>4
union
select sl from b
where u_state>4
union
select sl from c
where u_state>4
select sl from a
where u_state>3
union
select sl from b
where u_state>3
union
select sl from c
where u_state>3
----dt11
select sl from a
where u_state>4
union
select sl from b
where u_state>4
union
select sl from c
where u_state>4我想要的结果是select dt10.sl,dt11.sl from dt10,dt11这样的,但是 如果我把dt10,dt11都按上边的写 那太长了,
想在一个select dt.sl,dt.sl from dt 中出来上面的样子
先说说我的这个东西的意思
select dt10.sl wsl,dt11.sl qsl,bm from (slect sl from a where u_state>4) dt10,
(slect sl from a where u_state>3) dt11 where dt11.bm=dt10.bm大概意思就是上面那个 但是我这个dt10,还有dt11 很长
通过上面也年看出来 dt10和dt11的差别就在于 u_state,我的想法是可不可以通过一条语句实现我要的结果是这样的
bm dt10.sl dt11.sl
1 234 567
2 342 4545
where t1.u_state > 4
and t2.u_state > 3
and t1.bm = t2.bmu_state > 3 中有记录满足 u_state > 4
会产生重复数据吧?
但是还是很长 还是放不了平台上
最后使用视图解决了
--这样?
select sl from a
where u_state>3 and u_state!=4
union
select sl from b
where u_state>3 and u_state!=4
union
select sl from c
where u_state>3 and u_state!=4