oracle百分比怎么求,Oracle 百分比

oracle 怎么求累計(jì)百分比

用分析函數(shù)就可以了

從策劃到設(shè)計(jì)制作,每一步都追求做到細(xì)膩,制作可持續(xù)發(fā)展的企業(yè)網(wǎng)站。為客戶提供網(wǎng)站制作、成都做網(wǎng)站、網(wǎng)站策劃、網(wǎng)頁(yè)設(shè)計(jì)、主機(jī)域名、虛擬空間、網(wǎng)絡(luò)營(yíng)銷、VI設(shè)計(jì)、 網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,以客戶的口碑塑造優(yōu)易品牌,攜手廣大客戶,共同發(fā)展進(jìn)步。

select name ,quantity/sum(quantity)over(order by name) from 表名

oracle 給統(tǒng)計(jì)多個(gè)字段的數(shù)據(jù)結(jié)果 求之間的百分比

round((CountDelayed/CountOntimeAir)*100,2) 這個(gè)時(shí)候是還不能用CountDelayed,CountOntimeAir字段的,要在外面加一層;

COUNT(CASE WHEN AIR_DATE = '2013-10-21' THEN 1 ELSE 0 END) 這里你的本意是用sum的吧?count可能不是你想要的結(jié)果.

oracle 求百分比,例如:a/b*100=0.12,連接百分號(hào)(a/b*100)||'%',結(jié)果則變成.12%,想要顯示 0.12%,怎么辦

to_char(a/b*100,'fm999999990.999999999')||'%'

函數(shù):to_char(數(shù)字,格式),格式小數(shù)點(diǎn)前面一位是零。

oracle 求百分比

select sum(col2)/count(*) from

(select col1, case when col2=1 then 1 else 0 end col2 from test1) group by col1;

SQL select sum(col2)/count(*) from (select col1, case when col2=1 then 1 else 0 end col2 from test1) group by col1;

SUM(COL2)/COUNT(*)

------------------

.5

.75

-----------------------------------補(bǔ)充-----------------------------------

如果要加上百分比的,做些小處理即可

SQL select (sum(col2)*100/count(*))||'%' from

(select col1, case when col2=1 then 1 else 0 end col2 from test1) group by col1;

(SUM(COL2)*100/COUNT(*))||'%'

-----------------------------------------

50%

75%

oracle中如何求百分比?

實(shí)現(xiàn)代碼:

ELECT(CASE?WHEN?db_psndoc.age=30?THEN?'30歲以上'

WHEN?db_psndoc.age30?THEN?'30歲及以下'?END)

ranges,?COUNT(*) rs ,100*round(COUNT(*)/SUM(COUNT(*))

OVER(),4)||'%'?percent?FROM?bd_psnd

GROUP?BY?CASE

WHEN?bd_psndoc.age=30?then?'30歲及以下'

WHEN?db_psndoc.age=30?THEN?'30歲以上'

END

擴(kuò)展資料

sum(..) over(..)用法分析:

sum(…) over( ),對(duì)所有行求和;

sum(…) over( order by … ), 連續(xù)求和;

sum(…) over( partition by… ),同組內(nèi)所行求和;

sum(…) over( partition by… order by … ),同第1點(diǎn)中的排序求和原理,只是范圍限制在組內(nèi)。

over不能單獨(dú)使用,要和分析函數(shù):rank(),dense_rank(),row_number(),sum()等一起使用。

over函數(shù)的參數(shù):over(partition by columnname1 order by columnname2)

含義,按columname1指定的字段進(jìn)行分組排序,或者說(shuō)按字段columnname1的值進(jìn)行分組排序。

例子:

select deptno,ename,sal,

sum(sal) over (partition by deptno order by ename) 部門(mén)連續(xù)求和,--各部門(mén)的薪水"連續(xù)"求和

sum(sal) over (partition by deptno) 部門(mén)總和, -- 部門(mén)統(tǒng)計(jì)的總和,同一部門(mén)總和不變

oracle如何求百分比

SQL select to_char( 0.191 * 100) || '%' AS percent_zy_js from dual;

PERCENT_ZY

----------

19.1%

根據(jù)上面的運(yùn)行結(jié)果。

你的 SQL 可以修改為:

to_char( (sum(zy_js_to_rs)/sum(enterprise_to_rs)) * 100 ) || '%' AS percent_zy_js

本文標(biāo)題:oracle百分比怎么求,Oracle 百分比
文章位置:http://www.muchs.cn/article8/hsseip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、做網(wǎng)站、靜態(tài)網(wǎng)站、ChatGPT、電子商務(wù)、面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)