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. [转]Create Custom Exception Filter in ASP.NET Core

    本文转自:http://www.binaryintellect.net/articles/5df6e275-1148-45a1-a8b3-0ba2c7c9cea1.aspx In my previou ...

  2. Android开发过程中部分报错解决方法。

    初学Android,最近在使用zxing开发一个条码扫描解析的安卓项目中,遇到以下几个问题.贴出来以供参考. 1.Http请求错误    Android4.0以上要求不能把网络请求的操作放在主线程里操 ...

  3. The Dangers of the Large Object Heap(转载,LOH内存碎片情景重现)

    原文地址:https://www.simple-talk.com/dotnet/.net-framework/the-dangers-of-the-large-object-heap/ You'd h ...

  4. shiro 安全管理框架配置

    step1  web.xml <!-- Shiro filter start --> <filter> <filter-name>shiroFilter</f ...

  5. SharePoint 2013 - User Custom Action

    1. User Custom Action包含Ribbon和ECB,以及Site Action菜单等,参考此处: 2. 系统默认ECB的Class为: ms-core-menu-box --> ...

  6. Rational ClearCase 系列

    Base + UCM 系列参考:http://blog.csdn.net/hhg208/article/details/5749050

  7. linux下使用ntfs-3g挂载NTFS出错

    挂载报错如下图: 根据图中的报错:The disk contains an unclean file system (0, 0). 在网上搜索了一下原因,由于之前Windows系统未被正常关闭产生了错 ...

  8. ORA-01795: 列表中的最大表达式数为1000的解决方法

    IN中的数据量不能超过1000条. 解决方案:把条件分成多个少于1000的IN即: DELETEFROMT_MM_SECTION_SITE_UPDATEWHERE T.T_MM_SECTION_SL_ ...

  9. fstat、stat和lstat 区别(转)

    fstat.stat和lstat 区别(转) stat系统调用系列包括了fstat.stat和lstat,它们都是用来返回“相关文件状态信息”的,三者的不同之处在于设定源文件的方式不同. 1 首先隆重 ...

  10. LAB2 软件测试 Selenium上机实验 2017

    1.安装SeleniumIDE插件 打开Firefox——>菜单栏——>附加组件——>获取附加组件——>查看更多附加组件——>搜索框输入SeleniumIDE并查找——& ...