oracle求和問題,不要分組條件,只要求和

2021-03-12 14:56:35 字數 1091 閱讀 2483

1樓:

select sum(sum(a)) sum(a),sum(sum(b)) sum(b) from table;

#就是求sum(a)列的和,然後取別名還是sum(a)。同理sum(b)。

就這樣就行了,,,

感覺你題目好像搞複雜了【改為下面這樣】

id a b

1 3 55

2 55 62

需要結果如下----------------

sum(a) sum(b)

58 117

直接select sum(a) ,sum(b) from table;就可以了*****=

2樓:匿名使用者

select sum(a) a,sum(b) b from table

這樣就可以了

只要 都是分組函式 就可以

3樓:匿名使用者

我只是來看看不說話的

4樓:匿名使用者

你要查的是橫向之和還是縱向??

oracle條件求和問題,高分求解!!! 15

5樓:匿名使用者

用下面這個語句試試,我沒有測試,憑空想象的。

select mbr,sum(owe) from tablewhere (mbr in ( select mbr from table where type=11) and type !=21) or (mbr not in ( select mbr from table where type=11)) group by mbr

還有乙個辦法(總的-type=11的mbr中type=21的)(子查詢計算那裡可能有點問題,因為只有乙個grp所以沒有group by也可以的):

select sum(owe)-(select sum(owe) from table where mbr in ( select mbr from table where type=11) and type=21) from table

oracle小問題關於 問題如下

select 問題 to char 0.34522,99999999990.99 from dual 其中0表示該位沒有值時需要補0,小數點後的99表示保留兩位小數 自動四捨五入 小數點前的一串9必須夠長。select 問題 to char round 0.34522,2 0.00 from dua...

oracle資料庫問題使用索引

建立索引語法看下面引用的內容 建立好索引之後你查詢過程中資料庫會自己使用的。索引介紹 1.1 索引的建立語法 create uniuqe bitmap index on asc desc,asc desc,tablespace storage logging nologging compute st...

Oracle中查詢結果替換的問題

select name,case when id 3 then 高 else 低 end from tab 如果要你那個期望結果,必須要分開考慮。select 組,sum 數量 max case when 狀態 2 then 小 else null end from tab where 狀態 2 g...