ORACLE中如何獲取SUM

時間 2021-08-11 17:04:19

1樓:

select

(select sum(value) from a where type=1)+

(select sum(value) from b where type=1) as total

from dual;

2樓:匿名使用者

將2個表的結果集合起來(union all),再對結果集統計,其他還有很多方法

select sum(k.value) from (select type,value from a where type=1

union all

select type,value from b where type=1

) k沒有時,就分組,看看效果

select type, sum(k.value) from (select type,value from aunion all

select type,value from b) k group by k.type

3樓:匿名使用者

select sum(value) from

(select * from a where type=1 union all select * from b where type=1)

你試試看上面的sql

oracle中sum如何使用,在oracle中按要求統計行數,怎麼運用sum和count函式?

select 分組的列,sum 要求和的列 from 表group by 分組的列 如 select 地區,sum 銷售額 from 銷售表group by 地區 按地區分組,把每個組即每個地區的銷售額求和。 拾 忔 sum 是求和函式 例如 select sum 需要求和的列名 from tabl...

oracle中怎麼算sum分組取值彙總值啊?一直沒有頭緒

oracle中sum分組取值 彙總值用如下方法。如emp表中有如下資料 現要按deptno分組,求每組中sal的值 彙總值,可用如下語句 select deptno,sum sal select sum sal from emp from emp group by deptno 查詢結果 我tm不管...

oracle中如何資料庫,oracle中如何新建一個資料庫

oracle裡面不叫資料庫了,叫建立一個名稱空間建立表空間的語法是 create tablespace tablespacenamedatafile filename size integer k m autoextend off on 建立使用者 create user scce identifi...