可以,但要这样写:
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' ;
解决方案 »
- 关于序列的问题!!
- pl/sql中对sum结果求和的问题!!
- 关于 SELECT * FROM WHERE AA IN () 中的最大记录数的问题
- 急,oracle启动报错ORA-01092: ORACLE instance terminated. Disconnection forced
- 终于穿上最后一条裤子了,预祝大家新年快乐,来年共同进步
- 表空间'USERS'中无权限 ????
- 在一个10000万条记录的表里面有的number型字段,对这个字段索引,如何查询更快呢?
- 导入问题求助ORACLE高手,急!
- 小弟第一次用VC+Oracle做C/S软件,请大家说说注意事项
- oracle中如何移除所有用户对某张表的delete、update以及drop、alter功能呢?
- 我想实现不同数据库下两张相同表的数据同步该怎么做
- 帮我解决几个问题!
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
为什么不减?