转,Oracle中关于处理小数点位数的几个函数,取小数位数,Oracle查询函数
生活随笔
收集整理的這篇文章主要介紹了
转,Oracle中关于处理小数点位数的几个函数,取小数位数,Oracle查询函数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
關于處理小數點位數的幾個oracle函數()
1. 取四舍五入的幾位小數
select round(1.2345, 3) from dual;
結果:1.235
2. 保留兩位小數,只舍
select trunc(1.2345, 2) from dual;
結果:1.23select trunc(1.2399, 2) from dual;結果:1.23
3.取整數
返回大于或等于x的最大整數: SQL> select ceil(23.33) from dual;
結果: 24 返回等于或小于x的最大整數: SQL> select floor(23.33) from dual;
結果: 23 返回舍入到小數點右邊y位的x值:rcund(x,[y]) SQL> select round(23.33) from dual;
結果: 23 返回截尾到y位小數的x值:trunc(x,[y]) SQL> select trunc(23.33) from dual;
結果: 23 格式化數字The following are number examples for the to_char function.to_char(1210.73, '9999.9') would return '1210.7'to_char(1210.73, '9,999.99') would return '1,210.73'to_char(1210.73, '$9,999.00') would return '$1,210.73'to_char(21, '000099') would return '000021'to_char函數特殊用法to_char(sysdate,'d') 每周第幾天to_char(sysdate,'dd') 每月第幾天to_char(sysdate,'ddd') 每年第幾天to_char(sysdate,'ww') 每年第幾周to_char(sysdate,'mm') 每年第幾月to_char(sysdate,'q') 每年第幾季to_char(sysdate,'yyyy') 年比如要找某個時間為每周第幾天就可以SQL> select to_char(to_date('20070101','yyyymmdd'),'d') from dual;1.instr在Oracle/PLSQL中,instr函數返回要截取的字符串在源字符串中的位置。語法如下:instr( string1, string2 [, start_position [, nth_appearance ] ] )string1 源字符串,要在此字符串中查找。string2 要在string1中查找的字符串.start_position 代表string1 的哪個位置開始查找。此參數可選,如果省略默認為1. 字符串索引從1開始。如果此參數為正,從左到右開始檢索,如果此參數為負,從右到左檢索,返回要查找的字符串在源字符串中的開始索引。nth_appearance 代表要查找第幾次出現的string2. 此參數可選,如果省略,默認為 1.如果為負數系統會報錯。注意:如果String2在String1中沒有找到,instr函數返回0.應用于:Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g
舉例說明:select instr('abc','a') from dual; -- 返回 1
select instr('abc','bc') from dual; -- 返回 2
select instr('abc abc','a',1,2) from dual; -- 返回 5
select instr('abc','bc',-1,1) from dual; -- 返回 2
select instr('abc','d') from dual; -- 返回 0
注:也可利用此函數來檢查String1中是否包含String2,如果返回0表示不包含,否則表示包含。
?
轉載于:https://www.cnblogs.com/toowang/p/3781480.html
總結
以上是生活随笔為你收集整理的转,Oracle中关于处理小数点位数的几个函数,取小数位数,Oracle查询函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 哪款斗地主能好友同玩
- 下一篇: eclipse主题下载网站