ROUND(number[,decimals])

其中:number 待做截取处理的数值;
   decimals 指明需保留小数点后面的位数,可选项。需要注意的是,和trunc函数不同,对截取的数字要四舍五入

        1. 忽略它则截去所有的小数部分,并四舍五入;

        2. 如果y不为整数则截取y整数部分;

        3. 如果为负数则表示从小数点开始左边的位数,相应整数数字用0填充,小数被去掉。

实例:

 SQL>   select   round(1234.5678,3)   from   dual;
ROUND(1234.5678,3)
——————
1234.568 SQL> select round(1234.5678,0) from dual;
ROUND(1234.5678,0)
——————
1235 SQL> select round(1234.5678,-2) from dual;
ROUND(1234.5678,-2)
——————-
1200 SQL> select round(5555.6666,2.1) from dual;
ROUND(5555.6666,2.1)
——————-
5555.67

TRUNC(for number) 函数处理number型数字

语法格式:TRUNC(number[,decimals])

其中: number 待做截取处理的数值;

    decimals 指明需保留小数点后面的位数,可选项,截取时并不对数据进行四舍五入

         1. 忽略它则截去所有的小数部分;

         2. 如果y不为整数则截取y整数部分;

         3. 如果为负数则表示从小数点开始左边的位数,相应整数数字用0填充,小数被去掉。

实例:

 select trunc(123.458) from dual --

 select trunc(123.458,1) from dual --123.4

 select trunc(123.458,-1) from dual --

 select trunc(5555.66666,2.1) -- 5555.66

trunc(for dates) 函数处理日期

语法格式:TRUNC(date[,fmt])

其中:date 一个日期值;fmt 日期格式。

该日期将按指定的日期格式截取;忽略它则由最近的日期截取。

实例:

 select trunc(sysdate) from dual;  --2017/2/13,返回当前时间

 select trunc(sysdate,'yy') from dual;  --2017/1/1,返回当年第一天

 select trunc(sysdate,'mm') from dual;  --2017/2/1,返回当月的第一天

 select trunc(sysdate,'d') from dual;  --2017/2/12,返回当前星期的第一天,即星期天

 select trunc(sysdate,'dd') from dual;  --2017/2/13,返回当前日期,今天是2017/2/13

 select trunc(sysdate ,'HH24') from dual;  --2017/2/13 15:00:00,返回本小时的开始时间

 select trunc(sysdate ,'MI') from dual;  --2017/2/13 15:13:00,返回本分钟的开始时间,TRUNC()函数没有秒的精确

ROUND()和TRUNC()函数的更多相关文章

  1. round()和trunc()函数的应用

    http://blog.chinaunix.net/uid-7801695-id-68136.html round()和trunc()函数的应用 关键字: round()和trunc()函数的应用  ...

  2. oracle的round函数和trunc函数

    --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual --2013- ...

  3. Oracle中trunc函数、round 函数、ceil函数和floor函数的使用

    Oracle中trunc函数.round 函数.ceil函数和floor函数的使用 1.1trunc函数处理数字 trunc函数返回处理后的数值,其工作机制与ROUND函数极为类似,只是该函数不对指定 ...

  4. Delphi 常用函数(数学函数)round、trunc、ceil和floor

    源:Delphi 常用函数(数学函数)round.trunc.ceil和floor Delphi 常用函数(数学) Delphi中怎么将实数取整? floor 和 ceil 是 math unit 里 ...

  5. Oracle trunc()函数的用法及四舍五入 round函数

    --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysdate) from dual  --2011 ...

  6. 函数round和trunc

    1.round函数. round函数能够按照数学规则进行四舍五入的进位,以保留小数点后要求的位数. 使用方法为 round(<小数>,<保留的位数>) 下面是两个例子: ) f ...

  7. Oracle的取整和四舍五入函数——floor,round,ceil,trunc使用说明

    Oracle的取整和四舍五入函数——floor,round,ceil,trunc使用说明 FLOOR——对给定的数字取整数位SQL> select floor(2345.67) from dua ...

  8. 问题:oracle floor;结果:Oracle的取整和四舍五入函数——floor,round,ceil,trunc使用说明

    Oracle的取整和四舍五入函数——floor,round,ceil,trunc使用说明 (2011-04-06 16:10:35) 转载▼ 标签: 谈 分类: 渐行渐远 FLOOR——对给定的数字取 ...

  9. delphi的取整函数round、trunc、ceil和floor

    delphi的取整函数round.trunc.ceil和floor 首先引入math单元 uses math; 1.Round(四舍六入五留双) 功能说明:对一个实数进行四舍五入.(按照银行家算法) ...

随机推荐

  1. 关于supersocker的数据传输中遇到的问题

    最近在学socket,在使用socket时数据的传输与接口都是byte,所以文本与文件的传输只要对传过来的byte处理好就可以. 但是在supersocket上,我却花费了很长的时间.原因如下: 1. ...

  2. bootstrap dialog对话框,完成操作提示框

    1. 依赖文件: bootstrap.js bootstrap-dialog.js bootstrap.css bootstrap-dialog.css 2.代码 BootstrapDialog.co ...

  3. SQL:Example Uses of the SUBSTRING String Function

    ---Example Uses of the SUBSTRING String Function --http://www.sql-server-helper.com/tips/tip-of-the- ...

  4. 常用DOM结构方法总结

    ---内容开始--- 获取元素的方法: getElementById() 通过ID名获取元素 getElementsByTagName() 通过元素(标签)名称 getElementsByClassN ...

  5. Oracle 修改任何用户的密码

    1.通过sys用户以sysdba身份登陆: 2.修改用户密码:  alter user 用户名 identified by 密码; 比如修改system的密码为 manager : alter use ...

  6. linux常用指令集-持续更新...

    0.查看所有java进程GC情况:for i in `jps|egrep -v "Jps|Launcher" |cut -d" " -f1`;do pwdx $ ...

  7. window medio player 完美代码

    var arr = [               '<object width="240" height="240" align="basel ...

  8. Qt 静态编译发布和动态编译发布

    静态编译发布 你写了一个小型Qt程序,发布的时候不想要一大堆dll文件,就只想打包成一个exe文件,那么就需要用到静态编译. 下面的教程就是Qt静态编译环境配置 Qt5.6静态编译包下载地址 1.下载 ...

  9. Android获取手机安装的浏览器列表

    最近碰到一个同事询问如何查询本地安装的浏览器列表,其使用的代码如下: public static List<ResolveInfo> getBrowserList(Context cont ...

  10. 自定义Powershell提示符

    实现效果: 实现原理: Powershell将个人配置脚本文件的地址存放在$profile变量中, 通过修改该变量达到想要的目的. 实现过程: 1>创建一个新的配置脚本: 2>编辑脚本内容 ...