SQL --- with as 语法

来源:互联网 发布:hello world java 编辑:程序博客网 时间:2024/06/05 14:51

 with 名称 as

 --with 名称 as with tTable as (select xmk.*, qk.nd, qk.zjjh from MW_APP.MWV_JX_JGDX_JGXMK xmk, mw_app.mwt_ud_jgdx_ndtzqk qk where xmk.OBJ_ID = qk.xmid and kb = '2') select 上报单位,规划年度,count(*) 数量, sum(zjjh) 总投资 from (select case when j.DSGS is null then j.bzbmmc else j.DSGSMC end 上报单位,j.ND 规划年度,j.zjjh from tTable j where 1=1 and j.kb = '2' and nvl(j.SFGSBB,'否')<>'是'and to_char(j.XMKSSJ,'yyyy-mm') >='2010-01' and to_char(j.XMKSSJ,'yyyy-mm') <='2010-11'and j.BZBM in (select obj_id from mw_sys.mwt_pd_deps t start with obj_id='63EBEC8E-E766-40D7-ACF4-FEA945102112-00168' connect by prior obj_id=sjbm)) group by 上报单位,规划年度 order by 上报单位,规划年度