关于处理小数点位数的几个oracle函数()
1. 与四舍五进的几位小数
select round(1.2345, 3) from dual;
功能:1.235
2. 保存两位小数,只舍
select trunc(1.2345, 2) from dual;
功能:1.23
select trunc(1.2399, 2) from dual;
功能:1.23
3.与整数
返回大年夜于或便是x的最大年夜整数:
功能:
返回便是或小于x的最大年夜整数:
功能:
返回舍进到小数点右边y位的x值:rcund(x,[y])
功能:
返回截尾到y位小数的x值:trunc(x,[y])
功能:
格式化数字
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.
重视:
若是String2正在String1中没有找到,instr函数返回0.
利用于:
举例道明:
select instr("abc","a") from
dual;
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暗示不搜罗,不然暗示搜罗
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21475970/viewspace-1115183/ ,如需转载,请注明出处,否则将追究法律责任。