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

時間 2021-10-27 04:37:38

1樓:匿名使用者

select 分組的列,sum( 要求和的列) from 表group by 分組的列

如:select 地區,sum(銷售額) from 銷售表group by 地區

按地區分組,把每個組即每個地區的銷售額求和。

2樓:拾_忔

sum 是求和函式

例如: select sum(需要求和的列名)from table

3樓:

sum是求和函式

例:select sum(列名) from 表名

意思是計算該列的總和!

4樓:匿名使用者

sum是聚合函式,根據分組求和

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

5樓:知道小爺

在oracle中,sum一般用於統計某列的和,count用於統計行數。

工具:oracle 10g

步驟:1、oracle中emp表有如下資料:

2、要求按deptno欄位統計每個deptno下有多少行資料,可用如下語句:

select deptno,count(*) from emp group by deptno;

3、查詢結果:

4、要求按deptno欄位統計每個deptno下的sal的和是多少,可用如下語句:

select deptno,sum(sal) from emp group by deptno;

5、查詢結果:

其中:sum、count等在oracle中叫聚合函式,聚合函式對一組值執行計算並返回單一的值。除了 count以外,聚合函式忽略空值。

聚合函式經常與 select語句的group by子句一同使用。

6樓:丶花兒開在雨季

如果按某些欄位統計行數,而這些欄位有變化,用sum 和 decode 函式比較好吧

7樓:周生

group by試試

oracle中如何獲取sum?

8樓:

select

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

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

from dual;

9樓:匿名使用者

將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

10樓:匿名使用者

select sum(value) from

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

你試試看上面的sql

ORACLE中如何獲取SUM

select select sum value from a where type 1 select sum value from b where type 1 as total from dual 將2個表的結果集合起來 union all 再對結果集統計,其他還有很多方法 select sum ...

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...