select id , name,spec,amount sum(costs)
from
select id , name,spec,amount,sum(costs) costs
from table_A
where 、、、
group by id , name,spec,amount
union all
select id , name,spec,amount,sum(costs) costs
from table_B
where 、、、
group by id , name,spec,amount)group by id , name,spec,amount
from
select id , name,spec,amount,sum(costs) costs
from table_A
where 、、、
group by id , name,spec,amount
union all
select id , name,spec,amount,sum(costs) costs
from table_B
where 、、、
group by id , name,spec,amount)group by id , name,spec,amount
解决方案 »
- 求助oracle 11插入数据的问题。
- 一个sql语句..
- 求助oracle中SQL动态执行的问题,急!!
- update ..... (比较更新)!
- 寻ORACLE高手,真金白银悬赏!!!!!
- 请教大家,怎么样使用Access 把ORACLE 的数据导入进去,急!!谢谢
- oracle blob 字段,我想实现两个数据库之间的复制怎么办?
- 在一台服务器上能同时装Oracle9iAS的infrastructure和portal吗?机器重启后如何重起服务?急
- vb6通过Microsoft ODBC for Oracle访问oracle时候发现有重大错误,请各位大虾指点!!
- 一样的代码,一样的库结构,在sqlserver中可以,在oracle不可以
- decode函数疑问
- 急!oracle中用什么语句修改数据库表名!
from
(select id , name,spec,amount,costs costs
from table_A
union all
select id , name,spec,amount,costs costs
from table_B)
group by id , name,spec,amount这样执行的性能能比每个select都加group好些吧
我用你的方法试了,提示 无效的列名还有其它方法嘛?
请指教
select id , name,spec,amount,sum(a.costs)
from table_A a
where 、、、
group by id , name,spec,amount select id , name,spec,amount,sum(b.charges)
from table_B b
where 、、、
group by id , name,spec,amounta.costs 和 b.charges 的数据类型是一样的我现在需要得到 按照 id , name,spec,amount 分组的 sum(a.costs+b.charges)该如何写?谢谢
group by 时起个别名COST就行了:select id , name,spec,amount sum(COST)
from
(
select id , name,spec,amount,sum(a.costs) COST
from table_A a
where 、、、
group by id , name,spec,amountunion all select id , name,spec,amount,sum(b.charges) COST
from table_B b
where 、、、
group by id , name,spec,amount)
group by id , name,spec,amount