新聞中心
oracle去掉數(shù)字后面的0
給你做個試驗?zāi)憔椭懒?/p>

創(chuàng)新互聯(lián)建站專注于梅江網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供梅江營銷型網(wǎng)站建設(shè),梅江網(wǎng)站制作、梅江網(wǎng)頁設(shè)計、梅江網(wǎng)站官網(wǎng)定制、重慶小程序開發(fā)服務(wù),打造梅江網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供梅江網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
create?table?test
(id?varchar2(6));
insert?into?test?values?('120000');
insert?into?test?values?('120010');
insert?into?test?values?('120200');
insert?into?test?values?('123000');
insert?into?test?values?('123001');
commit;
執(zhí)行第一遍:
update?test?set?id=substr(id,1,5)?where?id?like?'%0';
commit;
此時結(jié)果:
執(zhí)行第二遍:
update?test?set?id=substr(id,1,4)?where?id?like?'%0';
commit;
后邊就不舉例了,也就是語句執(zhí)行4遍,需要修改里邊的參數(shù)。
oracle中 取小數(shù)部分函數(shù)
select 12.23-ceil(12.23) from dual
--結(jié)果 -0.77
select substr(12.23-floor(12.23),2,10) from dual;
--這個東西做不到通用沒什么價值
--如果
select substr(12.231111111111111-floor(12.231111111111111),2,10) from dual;
--結(jié)果不會是231111111111111,而是2311111111
select ltrim(0.55523-floor(0.55523),'0.') from dual;
--這個比較有代表性
--1
select substr(12.25,instr(12.25,'.')+1,length(12.25)) from dual;
--結(jié)果 25
--2
select A.a*power(10,length(A.a)-1) from
(select trunc(12.25333,length(12.25333))-trunc(12.25333,0) a from dual) A
--結(jié)果 25333
--方法很多的,看你想怎么個實現(xiàn)方法。最好做成函數(shù),通用一點。
oracle怎么去小數(shù)點后兩位
SQL SELECT
2 TO_CHAR(123,'9990.00') A,
3 TO_CHAR(5.8,'9990.00') B,
4 TO_CHAR(.46,'9990.00') C
5 FROM
6 dual;
A B C
---------------- ---------------- ----------------
123.00 5.80 0.46
SQL
ORACLE 的SQL小數(shù)問題
這個應(yīng)該不是SQL的問題
這個問題在財務(wù)上經(jīng)常出現(xiàn),也是財務(wù)軟件要求必須做到的一個事
所以這個時候就必須把小數(shù)點后面的位數(shù)放的非常長,然后根據(jù)種類與量來確定劃分幾個
這是個程序算法題
呵呵
本文名稱:oracle如何去除小數(shù),oracle如何保留一位小數(shù)
文章來源:http://www.dlmjj.cn/article/dsicdje.html


咨詢
建站咨詢
