ORACLE中如何獲取SUM

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

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中建立儲存過程,來迴圈獲取a表中存放的查詢sql語句並一條一條的執行該sql語句並存下來

create or replace package body pkg a testpackage is procedure pkg a testprocedure prm 引數 in varchar2,prm 返回值 out number,prm 錯誤資訊 out varchar2 is type ...

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

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