SQL code: create tmp as select a,b,a*c,0 as a1 from tableA where a>10;
update tmp q set q.a1 = (select sum(w.a1) from tableB w where w.b = q.b);
select * from tmp;
drop table tmp;
这个是我简化了的SQL语句,请问有更简便的方法吗? 想用视图的,但不知道怎么写SQL语句好!
因为不想每次都create表!万一多人用的时候就出错了!临时表? 使用ORACLE全局临时表,一次创建,永久使用。 参考 http://www.ccctttv.cn/Promote.aspx?UID=ht8326 你是从两个表获取数据,聚合不包括所有的字段.估计只能这么写了. 2楼的兄弟说详细点行吗,谢谢啦 create or repleace view a as select q.a,q.b,q.a*q.c as ac,0 as a1 from tableA q,tableB w where w.b=q.b and q.a>10
create or repleace view a as select q.a,q.b,q.a*q.c as ac,0 as a1 from tableA q,tableB w where w.b=q.b and q.a>10