日期:2014-05-16 浏览次数:20447 次
select r.xm, substr(r.csrq,1,4)||'年'||substr(r.csrq,5,2)||'月'||substr(r.csrq,7,2)||'日' csrq, (select dictvalue from zh_dictvalue where dictcode=xb and dictname='rk_xb') xb, (select dictvalue from zh_dictvalue where dictcode=mz and dictname='rk_mz') mz, (select dictvalue from zh_dictvalue where dictcode=ssxq and dictname='rk_xzqh') ssxq, xz, xp, xz, fwcs from czrk_jbxx r,rk_zpxx p where r.gmsfhm=p.gmsfhm and rownum<2朋友看了一会,然后问我 (select dictvalue from zh_dictvalue where dictcode=xb and dictname='rk_xb') xb, (select dictvalue from zh_dictvalue where dictcode=mz and dictname='rk_mz') mz, (select dictvalue from zh_dictvalue where dictcode=ssxq and dictname='rk_xzqh') ssxq, 这里如何优化,也就是符合条件的三条记录要合并成一条记录.
select * from ( select name, lead(name,1) over (order by name) as name1, lead(name,2) over (order by name) as name2, lead(name,3) over (order by name) as name3, lead(name,4) over (order by name) as name4 from tb_customer where 条件 ) t where t.name4 is not null
select * from ( select dictvalue as mz, lead(dictvalue,1) over (order by dictcode) as ssxq, lead(dictvalue,2) over (order by dictcode) as xb, from zh_dictvalue where (dictcode=xb and dictname='rk_xb') or (dictcode=mz and dictname='rk_mz') or (dictcode=ssxq and dictname='rk_xzqh') ) t where t.ssxq not null
注意在order by dictcode后,苛as后面的名称被调整了.否则dictvalue和命名的列就不对应了.