oracle中的turnc,round,floor,ceil,coalesce函数
这四个函数有点类似java中的函数,首先是
trunc(number,[decimals]) 这个函数类似截取函数
number:表示你要输入的数
decimals(小数): 表示你要截取的位数【正数表示小数点向右保留多少位,负数向左依次置零且小数点右边的截断】
eg:
- select trunc(35.34,1) from dual; result: 35.3
- select trunc(35.34,3) from dual; result:35.34
- select trunc(35.34,-1) from dual; result:30
- select trunc(35.34,-2) from dual; result: 0;
trunc(data,[format]) --这个是针对于日期来说的
data: 是一个日期值
format: 这是一个日期格式
- 1.select trunc(sysdate) from dual --2016-08-06 今天的日期为2016-08-06
- 2.select trunc(sysdate, 'mm') from dual --2016-08-01 返回当月第一天.
- 3.select trunc(sysdate,'yy') from dual --2016-08-01 返回当年第一天
- 4.select trunc(sysdate,'dd') from dual --2016-08-06 返回当前年月日
- 5.select trunc(sysdate,'yyyy') from dual --2016-08-01 返回当年第一天
- 6.select trunc(sysdate,'d') from dual --2016-08-06 (星期天)返回当前星期的第一天
- 7.select trunc(sysdate, 'hh') from dual --2016-08-06 17:00:00 当前时间为17:35
- 8.select trunc(sysdate, 'mi') from dual --2016-08-06 17:35:00 TRUNC()函数没有秒的精确
round(number,[decimals]) 这个函数其实就是一个四舍五入函数
number: 要处理的数值
decimals: 四舍五入后,要保留几位
- select round(123.346,0) from dual; result: 0
- select round(123.346,2) from dual; result: 123.35
- select round(-123.346,2) from dual; result: -123.35
ceil和floor函数
ceil(n) 取大于等于n的最小整数
floor(n) 取小于等于n的最大整数
eg:
- select ceil(34.3) from dual; result: 35
- select floor(34.3) from dual; result: 34
coalesce:
COALESCE (expression_1, expression_2, ...,expression_n)依次参考各参数表达式,遇到非null值即停止并返回该值。如果所有的表达式都是空值,最终将返回一个空值。
使用COALESCE在于大部分包含空值的表达式最终将返回空值。
eg:
SELECT COALESCE(NULL,NULL,3,4,5) FROM dual result: 3
oracle中的turnc,round,floor,ceil,coalesce函数的更多相关文章
- Oracle中的NVL,NVL2,NULLIF以及COALESCE函数使用
首先注意空(null)值,空值加任何值都是空值,空值乘任何值也都是空值,依此类推. 1.NVL函数 NVL函数的格式如下:NVL(expr1,expr2) 含义是:如果oracle第一个参数为空那么显 ...
- SQL 中详解round(),floor(),ceiling()函数的用法和区别?
SQL 中详解round(),floor(),ceiling()函数的用法和区别? 原创 2013年06月09日 14:00:21 摘自:http://blog.csdn.net/yueliang ...
- MATLAB中取整函数(fix, floor, ceil, round)的使用
MATLAB取整函数 1)fix(x) : 截尾取整. >> fix( [3.12 -3.12]) ans = 3 -3(2)floor(x):不超过x 的最大整数.(高斯取整) & ...
- paper 68 :MATLAB中取整函数(fix, floor, ceil, round)的使用
MATLAB取整函数 1)fix(x) : 截尾取整. >> fix( [3.12 -3.12]) ans = 3 -3 (2)floor(x):不超过x 的最大整数.(高 ...
- C++中的 Round(),floor(),ceil()
2.1 2.6 -2.1 -2.6floor : 不大于自变量的最大整数 2 ...
- Matlab中的取整-floor,ceil,fix,round
FLOOR Round towards minus infinity. FLOOR(X) rounds the elements of X to the nearest integers toward ...
- sql中详解round(),floor(),ceiling()函数的用法和区别?
round() 遵循四舍五入把原值转化为指定小数位数,如:round(1.45,0) = 1;round(1.55,0)=2floor()向下舍入为指定小数位数 如:floor(1.45,0)= 1; ...
- 【Matlab】取整函数:fix/round/floor/ceil
fix-向零方向取整.(向中间取整) round-向最近的方向取整.(四舍五入) floor-向负无穷大方向取整.(向下取整) ceil-向正无穷大方向取整.(向上取整)
- Oracle中与日期时间有关的运算函数
1 ADD_MONTHS 格式:ADD_MONTHS(D,N) 说明:返回日期时间D加N月后对应的日期时间.N为正时则表示D之后:N为负时则表示为D之前:N为小数则会自动先删除小 ...
随机推荐
- PAT 团体程序设计天梯赛-练习集 L1-002. 打印沙漏
本题要求你写个程序把给定的符号打印成沙漏的形状.例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号:各行符号中心对齐:相邻两 ...
- Spring Security(12)——Remember-Me功能
目录 1.1 概述 1.2 基于简单加密token的方法 1.3 基于持久化token的方法 1.4 Remember-Me相关接口和实现类 1.4.1 Toke ...
- php基础(六)Include
本文内容来自http://www.w3school.com.cn/php/php_file.asp 服务器端包含 (SSI) 用于创建可在多个页面重复使用的函数.页眉.页脚或元素. include ( ...
- HDU 1509 Windows Message Queue(队列)
题目链接 Problem Description Message queue is the basic fundamental of windows system. For each process, ...
- 判断手机电脑微信 js
if ((navigator.userAgent.match(/(MicroMessenger)/i))) { //微信浏览器 //location.href=""; } else ...
- Objective-C中的instancetype与id的区别
一.什么是instancetype instancetype是clang 3.5开始,clang提供的一个关键字,表示某个方法返回的未知类型的Objective-C对象.我们都知道未知类型的的对象可以 ...
- java的string.split()分割特殊字符时注意点
[1]单个符号作为分隔符 String address="上海|上海市|闵行区|吴中路"; String[] splitAddress=address.s ...
- HttpServletResponse对象(一)
web服务器收到客户端的http请求,会针对每一次请求,分别创建一个用于代表请求的request对象,和代表响应的response对象. request和response对象既然代表请求和响应,那么我 ...
- 2015 Multi-University Training Contest 9
1001 Expression 式子不好推啊.见官方题解. 式子知道就方便了.处理好组合数和阶乘. 按区间长度从小到大递推完就好. # include <iostream> # inclu ...
- 第四题 (List)写一个函数reverseList,该函数能够接受一个List,然后把该List 倒序排列。 例如: List list = new ArrayList(); list.add(“Hello”); list.add(“World”); list.add(“Learn”); //此时list 为Hello World Learn r
package zuoye; import java.util.ArrayList; import java.util.List; public class Reverse01 { public st ...