Oracle 函数【笔记】

1. Oracle Round 函数 (四舍五入)










描述 : 传回一个数值,该数值是按照指定的小数位元数进行四舍五入运算的结果。


如果两个整数都和value值等距离,那么round函数将返回较大的那个整数值。如果value是一个整数,则返回的就是value本身







SELECT ROUND( number, [ decimal_places ] ) FROM DUAL



参数:



number : 欲处理之数值



decimal_places : 四舍五入 , 小数取几位 ( 预设为 0 )







Sample :



select round(123.456, 0) from dual; 回传 123



select round(123.456, 1) from dual; 回传 123.5



select round(123.456, 2) from dual; 回传 123.46



select round(123.456, 3) from dual; 回传 123.456



select round(-123.456, 2) from dual; 回传 -123.46

var a = float.round(3.5);                          // 计算结果为a = 4;4和3与3.5等距离,取较大的数4

var b = float.round(-3.5);                        // 计算结果为b = -3

var c = float.round(0.5);                          // 计算结果为c = 1;1和0与0.5等距离,取较大的数1

var d = float.round(-0.5);                        // 计算结果为d = 0



Round 函数都是采用 Banker's rounding(银行家舍入)算法,即四舍六入五取偶



2.mod(number1,number2)






两个数值相除并返回其余数。(取模)

如果任一表达式为      Null,则      result      也为      Null。任一表达式为      Empty      时按      0      来处理。

如:round(3.5)=4 ,round(4.5)=4





3. SUBSTR( string, start_position, [ length ] )
string is the source string.
start_position is the position for extraction. The first position in the string is always 1 .
length is optional. It is the number of characters to extract. If this parameter is omitted, substr will return the entire string.
for example:
 
 
 

    substr ( 'This is a test' , 6, 2) would return 'is'
    substr ( 'This is a test' , 6) would return 'is a test'
    substr ( 'TechOnTheNet' , 1, 4) would return 'Tech'
    substr ( 'TechOnTheNet' , - 3, 3) would return 'Net'
    substr ( 'TechOnTheNet' , - 6, 3) would return 'The'
    substr ( 'TechOnTheNet' , - 8, 2) would return 'On'



Be Continued ...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

春哥撩编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值