|
elect *
from (select new_djxh djxh,
hdzxqq,
hdzxqz,
rdyxqq,
rdyxqz,
max(dsqc_zspm_dm) dsqc_zspm_dm,
decode(count(*), 1, null, new_djxh) new_djxh,
max(sz_zspm) sz_zspm
from (select d.djxh dsqc_djxh,
d.zspm_dm dsqc_zspm_dm,
c.djxh dsqc_djxh,
c.zspm_dm sz_zspm,
nvl(d.djxh, c.djxh) new_djxh,
d.hdzxqq,
d.hdzxqz,
c.rdyxqq,
c.rdyxqz,
decode(d.zspm_dm, c.zspm_dm, null, 1) flag
from hx_zs.zs_hd_dqdehd_jg d
full outer join hx_rd.rd_sfzrdxxb c
on d.zgswskfj_dm like '1532301%'
and d.zsxm_dm = '10101'
and d.djxh = c.djxh
and d.zsxm_dm = c.zsxm_dm
and d.zspm_dm = c.zspm_dm
and (d.zfbz_1 = 'N' or d.zfbz_1 is null) --未作废
and d.hdzxqq < d.sjzxqz --核定执行期起小于实际执行期止
and d.sjzxqz >= sysdate
and (d.hdzxqz >= sysdate OR d.hdzxqz is null)
and d.hdzxqq >= c.rdyxqq
and d.hdzxqz <= c.rdyxqz
and c.yxbz = 'Y' --有效
and c.rdyxqq <= sysdate --当前有效
and c.rdyxqz >= sysdate)
where flag = 1
group by new_djxh,
hdzxqq,
hdzxqz,
rdyxqq,
rdyxqz)
where not (new_djxh = new_djxh and dsqc_zspm_dm = sz_zspm)
执行无结果
|
|