當前位置:首頁 » 編程語言 » sql如果分兩類組後求和
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sql如果分兩類組後求和

發布時間: 2022-12-22 14:23:33

sql SEVER分類匯總後求和

select sum(出口量) from (
select top 5 * from (
select 國家,sum(出口量) 出口量 from table group by 國家) aa order by 出口量 desc
)k

Ⅱ sql分組求和

select sum(case d when '1' then a when '2' then b else 0 end ) from 表 group by c

Ⅲ sql分組求和語句

1.如果2張表的欄位一致,並且希望插入全部數據,可以用這種方法:
INSERT INTO 目標表 SELECT * FROM 來源表;
insert into tablemubiao select * from tableinsert;
2.如果只希望導入指定欄位,可以用這種方法:
INSERT INTO 目標表 (欄位1, 欄位2, ...) SELECT 欄位1, 欄位2, ... FROM 來源表;
注意欄位的順序必須一致。
insert into tablemubiao(id) select id from tableinsert;

Ⅳ 怎麼用sql語句來實現分組求和

第二列第一行是不是寫錯了? 應該是5 ?

select 名稱,min(金額) 類型1,max(金額) 類型2,sum(金額) 金額合計 from 表名
group by 名稱 order by 1

Ⅳ SQL分組求和

selectnvl(job,'總計:'),
count(1)員工數量,
count(distinctdeptno)部門數量
from(selectdeptno,nvl(job,'')jobfromemp)a
groupbyrollup(job)
orderbyjob

以上是oracle語法,你試下。

Ⅵ sql分組求和

select sum(case d when '1' then (case e when 1 then aa when 2 then bb end ) when '2' then b else 0 end )
from 表 group by c

當然可以,你少了個then

Ⅶ sql 分類求和

分類求和需要用sun函數。

1、如emp表中數據如下:

Ⅷ sql 如何對指定的分組進行求和

子查詢 sum 求和 avg 平均

Ⅸ 怎麼把兩列的數據求和(先每列求和,再把結果再相加)sql資料庫

1、在數據中打開一個存在整數數值的表,然後可以看到右下角就有查看的表格數據。

Ⅹ sql 按類型分組求和

參考sql語句
select no ,
max(case when type=1 then type) else null end) type1,
max(case when type=2 then type) else null end) type2,
sum(case when type=1 then sumsource) else null end) source1,
sum(case when type=2then sumsource) else null end) source2,
from(
selct no , type, sum(source) sumsource
group by no,type
)