可以,但要这样写:
update ta a set a.hy=(
select x.aa-y.aa
from
(select b.dl aa,rownum rn from t0 b where b.rq='00') x,
(select c.dl aa ,rownum rn from t0 c where c.rq='01') y
where x.rn=y.rn
)
where a.rq='00' ;
update ta a set a.hy=(
select x.aa-y.aa
from
(select b.dl aa,rownum rn from t0 b where b.rq='00') x,
(select c.dl aa ,rownum rn from t0 c where c.rq='01') y
where x.rn=y.rn
)
where a.rq='00' ;
update df_rep_hyydflb a set a.qntq=
(select b.bydl from df_rep_hyydflb b
where b.tjbz='00' and b.hyfl='21000' and to_char(b.tjrq,'yyyy-mm')='2004-02'
)
-(select b.bydl from df_rep_hyydflb b
where b.tjbz='00' and b.hyfl='21020' and to_char(b.tjrq,'yyyy-mm')='2004-02'
)
-(select b.bydl from df_rep_hyydflb b
where b.tjbz='00' and b.hyfl='21030' and to_char(b.tjrq,'yyyy-mm')='2004-02'
)
where a.hyfl='21000' and to_char(a.tjrq,'yyyy-mm')='2005-02' and a.tjbz='00' ;
那我这个要怎么改呢?我还是没有太明白!谢谢了!
qntq=bydl(hyfl=21000)-bydl(hyfl=21020)-bydl(hyfl=21030)吗?
可以用:--21000
update df_rep_hyydflb a set a.qntq=
(select sum(decode(hyfl,'21000',bydl,'21020',-1*bydl,'21030',-1*bydl)) bydl
from df_rep_hyydflb b
where b.tjbz='00' and to_char(b.tjrq,'yyyy-mm')='2004-02'
)
where a.hyfl='21000' and to_char(a.tjrq,'yyyy-mm')='2005-02' and a.tjbz='00' ;
select t1.a,t1.b from tab1 t1 minus select t2.a,t2.b from tab2 t2;
贴主要根据需要来判断。
update df_rep_hyydflb a set a.qntq=
((select b.bydl from df_rep_hyydflb b
where b.tjbz='00' and b.hyfl='10020' and to_char(b.tjrq,'yyyy-mm')='2004-02')
minus (select b.bydl from df_rep_hyydflb b
where b.tjbz='00' and b.hyfl='21020' and to_char(b.tjrq,'yyyy-mm')='2004-02')
)
where a.hyfl='10020' and to_char(a.tjrq,'yyyy-mm')='2005-02' and a.tjbz='00' ;
第一个select结果为4
第二个select结果为1
但是update 后为4
为什么不减?