oracle中 trunc(),round(),ceil(),floor的使用
原文: http://www.2cto.com/database/201310/248336.html
1.round函数(四舍五入)
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
2.ceil和floor函数
ceil和floor函数在一些业务数据的时候,有时还是很有用的。 ceil(n) 取大于等于数值n的最小整数;
select ceil(1.5) a from dual; 返回2
select ceil(-1.5) a from dual; 返回-1 select floor(1.5) a from dual; 返回1
select floor(-1.5) a from dual; 返回-2
3.trunc函数
1)trunc函数处理数字
TRUNC(number[,decimals])
其中: number 待做截取处理的数值
select trunc(sysdate,'yyyy') from dual;--返回当年第一天.
select trunc(sysdate,'mm') from dual; --返回当月第一天.
select trunc(sysdate,'d') from dual;--返回当前星期的第一天.
select trunc(sysdate,'YYYY') from dual;
select trunc(sysdate,'MM') from dual;
select trunc(sysdate,'D') from dual;
FLOOR——对给定的数字取整数位
SQL> select floor(2345.67) from dual;
FLOOR(2345.67)
--------------
2345
CEIL--
返回大于或等于给出数字的最小整数
SQL> select ceil(3.1415927) from dual;
CEIL(3.1415927)
---------------
4
ROUND——按照指定的精度进行四舍五入
SQL> select round(3.1415926,4) from dual;
ROUND(3.1415926,4)
------------------
3.1416
TRUNC——按照指定的精度进行截取一个数
SQL> select trunc(3.1415926,4) from dual;
ROUND(3.1415926,4)
------------------
3.1415
oracle中 trunc(),round(),ceil(),floor的使用的更多相关文章
- Oracle ->> TRUNC, ROUND, CEIL, FLOOR
), ), CEIL(10.01), FLOOR(10.9999) FROM dual; 结果: TRUNC是直接截断小数位 ROUND是四舍五入 CEIL和FLOOR则是和SQL SERVER一样返 ...
- Oracle 数字操作。数字函数。mod(),trunc(),round(),ceil(),floor的使用
1,取整函数(ceil 向上取整,floor 向下取整) 第一种方式: ) from dual -- 取整 trunc (1.9) = 1 第二种方式 select ceil(66.6) N1,flo ...
- Oracle中trunc函数、round 函数、ceil函数和floor函数的使用
Oracle中trunc函数.round 函数.ceil函数和floor函数的使用 1.1trunc函数处理数字 trunc函数返回处理后的数值,其工作机制与ROUND函数极为类似,只是该函数不对指定 ...
- freemarker中的round、floor和ceiling数字的舍入处理
freemarker中的round.floor和ceiling数字的舍入处理 1.简易说明 (1)round:四舍五入 (2)floor:向下取整 (3)ceiling:向上取整 2.举例说明 < ...
- freemarker中的round、floor和ceiling数字的舍入处理(十七)
1.简易说明 (1)round:四舍五入 (2)floor:向下取整 (3)ceiling:向上取整 2.举例说明 <#--freemarker中的round.floor和ceiling数字的舍 ...
- oracle中的round()方法的用法
[oracle中的round()方法的用法] Round( ) 函数 传回一个数值,该数值是按照指定的小数位元数进行四舍五入运算的结果 oracle一般常用于计算表空间内存还有多少空间 语法 ROUN ...
- js中Math之random,round,ceil,floor的用法总结
1.Math.random(); 结果为0-1间的一个随机数(包括0,不包括1) 2.Math.floor(num); 参数num为一个数值,函数结果为num的整数部分(返回小于等于n的最大整数). ...
- 区分舍入函数fix/round/ceil/floor
1)fix(n)的意义是取小于n的整数(是向零点舍入的意思是往零的方向上靠),这是一类应用在整数取值上的函数,就如同以前我们所研究的求整问题: 例如:fix(pi)=3 ; fix(3.5)=3; ...
- java只能的round,ceil,floor方法的使用
三者均位于java.lange包下的Math类中 round: 在原来数字的基础上加上0.5后向下取整, 例如: Math.floor(11.5)=12; Math.floor(-11.5)=-11( ...
随机推荐
- MAC终端安装指定版本node
MAC终端安装指定版本node 安装brew 终端上运行 $ /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Home ...
- 如何在 Debian 9 下安装 LEMP 和 WHMCS 7.5
WHMCS 7.5 发布了,它开始支持 PHP 7.2,这里就写个简单的教程记录一下安装方式. 1.准备工作 首先,我们需要按照 在Debian 9 / Debian 8 下使用源安装方式安装 LEM ...
- PaaSoo云通讯-印度市场机遇与挑战并存
2019年4月16日,由白鲸出海举办的2019中印互联网大会(Global Connects India)在印度新德里举行,这次的大会主要涵盖了出海主题峰会.B2B展会.中印互联网高层圆桌等模块. 众 ...
- python3 ,AttributeError: module 'tensorflow' has no attribute 'merge_summary'
error:tensorflow有些方法属性被改了, self.summary_writer = tf.train.SummaryWriter(summary_dir)改为:summary.FileW ...
- leetcode个人题解——#34 Find First and Last Position of Element in Sorted Array
思路:先二分查找到一个和target相同的元素,然后再左边二分查找左边界,右边二分查找有边界. class Solution { public: , end = -; int ends; int lS ...
- 5个最优秀的微信小程序UI组件库
开发微信小程序的过程中,选择一款好用的组件库,可以达到事半功倍的效果.自从微信小程序面世以来,不断有一些开源组件库出来,下面5款就是排名比较靠前,用户使用量与关注度比较高的小程序UI组件库.还没用到它 ...
- 2.openldap安装
1.安装步骤如下 获取软件包 安装软件包(rpm或者源码编译) 生产openldap配置文件及数据库文件 配置 添加目录树条目 加载slapd进程 验证 2.所需安装包说明 openldap,open ...
- Python Pygame (4) 图像的变换
Pygame中的transform模块可以使得你能够对图像(也就是Surface对象)做各种动作,列如左右上下翻转,按角度转动,放大缩小......,并返回Surface对象.这里列举了transfo ...
- Python Pygame (3) 界面显示
显示模式: 之前使display模块的set_mode()的方法用来指定界面的大小,并返回一个Surface对象. set_mode()的原型如下: display.set_mode(resoluti ...
- Scrum立会报告+燃尽图(Beta阶段第二周第六次)
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2414 项目地址:https://coding.net/u/wuyy694 ...