SQL Fundamentals || Oracle SQL语言

SQL Fundamentals: Using Single-Row Functions to Customize Output使用单行函数自定义输出

SQL Fundamentals || Single-Row Functions || 字符函数 character functions

SQL Fundamentals || Single-Row Functions || 数字函数number functions

SQL Fundamentals || Single-Row Functions || 日期函数date functions

SQL Fundamentals || Single-Row Functions || 转换函数 Conversion function

SQL Fundamentals || Single-Row Functions || 通用函数 General function

数字函数number functions

  • Number functions - Accepts numeric input and returns numeric values. Functions under the category are ROUND, TRUNC, and MOD.

    • ROUND and TRUNC functions are used to round and truncate the number value.
    • MOD is used to return the remainder of the division operation between two numbers.

function

result

ROUND

Rounds value to a specified decimal

四舍五入

TRUNC

Truncates value to a specified decimal

截断一个值到一定的小数位,不管大于5小于5

MOD

Returns remainder of division

返回一个除数的余数

function

result

ROUND(45.926,2)

45.93

TRUNC(45.926,2)

45.92

MOD(1600,300)

100

function

purpose

ROUND(column | expression,n)

Rounds (四舍五入)the column, expression, or value to n decimal places(小数位) or, if n is omitted(省略), no decimal places (if n degative, numbers to the left of decimal point are rounded.)

如果n是负数,小数点左边四舍五入

SQL> SELECT ROUND(45.923,2),ROUND(45.923,0),ROUND(45.923,-1) FROM DUAL;

ROUND(45.923,2) ROUND(45.923,0) ROUND(45.923,-1)

--------------- --------------- ----------------

45.92              46               50

TRUNC(column | expression,n)

Truncates(截断) the column, expression, or value to n decimal places or, if n is omitted, n defaults to zero.

Like the ROUND function, the TRUC function can be used with date functions.

TRUNC函数也可以用作日期函数.

MOD(m,n)

Returns the remainder(余数) of m divided by n

Note : The MOD function is often used to determine whether a value is odd or even.

The MOD function is also the ORACLE hash function.

MOD函数经常被用于判断一个值是奇数还是偶数.

对数字进行处理,例如:四舍五入;

函数名称

描述

ROUND(数字 [,保留位数])

对小数进行四舍五入,可以指定保留位数,如果不指定,则表示将小数点之后的数字全部进行四舍五入

SELECT ROUND(789.652),ROUND(789.652,2),ROUND(789.652,-1) FROM DUAL;

ROUND(789.652) ROUND(789.652,2) ROUND(784.652,-1)

-------------- ---------------- -----------------

790           789.65               780

以上分别是不保留小数,保留两位小数,处理整数进位.

SELECT ename,job,sal,ROUND(sal/30,2) FROM emp;

TRUNC(数字 [,截取位数])

保留指定位数的小数,如果不指定,则表示不保留小数

SQL> SELECT TRUNC(789.652),TRUNC(789.652,2),TRUNC(789.652,-2) FROM DUAL;

TRUNC(789.652) TRUNC(789.652,2) TRUNC(789.652,-2)

-------------- ---------------- -----------------

789           789.65               700

MOD(数字,数字)

取模,求余数

SQL> SELECT MOD(10,3) FROM DUAL;

MOD(10,3)

----------

1

转载于:https://www.cnblogs.com/thescentedpath/p/numberfunctions.html

SQL Fundamentals || Single-Row Functions || 数字函数number functions相关推荐

  1. SQL Fundamentals || Oracle SQL语言

    对于SQL语言,有两个组成部分: DML(data manipulation language) 它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样,这4条命令是用来对数据 ...

  2. MySQL Functions 常用函数汇总

    Aggregate Functions (聚合函数) numeric functions round(5.73,1) -- 保留一位小数,做四舍五入结果5.7 truncate(5.6789,2) - ...

  3. UE3 Light Functions (光照函数)

    Light Functions (光照函数) Light Functions (光照函数) 概述 Decals(贴花) vs 光照函数 可以使用哪些材质表达式? Texture 2D(二维贴图) Te ...

  4. sql 语言-单值函数single row functions

    单行函数 Use functions to Perform calculations on data. Modifyi ndividual data items. Manipulate output ...

  5. oracle数字加 39,Oracle数据库之SQL单行函数—数字函数-Oracle

    Oracle数据库之SQL单行函数-数字函数 1.三角函数 SIN  ASIN  SINH COS  ACOS  COSH TAN  ATAN  TANH 对于上述三角函数,见名知意.做一个间断的练习 ...

  6. 来自python的【数字Number总结/Math数字函数】

    Number数字 在python的文档中,几个注意点: Math 模块不支持复数的函数,复数的函数是使用cmath来进行计算.所以绝大部都是不支持复数的. 在math模块下,除非显示的标注,否则返回浮 ...

  7. MySQL高级 - SQL技巧 - 数字函数与字符串函数

    数字函数 函数名称 作 用 ABS 求绝对值 SQRT 求二次方根 MOD 求余数 CEIL 和 CEILING 两个函数功能相同,都是返回不小于参数的最小整数,即向上取整 FLOOR 向下取整,返回 ...

  8. SAP HANA SQL系列四:数字函数

    数字函数 数字函数 ABS ACOS ASIN ATAN ATAN2 BINTOHEX BITAND CEIL COS COSH COT EXP FLOOR GREATEST HEXTOBIN LEA ...

  9. Oracle SQL数字函数

    数字函数: 操作符 含义 Round 四舍五入 Trunc 截断 Mod求余 Round:四舍五入(可以对年.月.日和数值等进行四舍五入) 例如:对数字进行四舍五入 Select round(34.5 ...

  10. SQL SERVER中用户定义标量函数(scalar user defined function)的性能问题

    SQL SERVER中用户定义标量函数(scalar user defined function)的性能问题 原文:SQL SERVER中用户定义标量函数(scalar user defined fu ...

最新文章

  1. linux下.rar的文件,Linux下.rar压缩文件处理 (RAR 4.11 for linux )
  2. PathRemoveFileSpec函数
  3. Jasypt 加密-引言
  4. 使用 vim 开发-编译-查错-运行/测试-调试最佳实践流程
  5. Python3 threading的多线程管理中的线程管理与锁
  6. logback:RollingFileAppender
  7. Burpsuite中protobuf数据流的解析
  8. php mysql计算距离_php mysql 计算经纬之间距离 范围内筛选
  9. 时间复杂度与空间复杂度的研究
  10. Leetcode重点题
  11. linux 脚本 日志文件,在linux下用脚本输出日志
  12. [学习]啦啦外卖定位修复,商家经纬度保存修复
  13. 产品分析之美团_米米米米粒口红_新浪博客
  14. 谷歌公开裸眼3D全息视频聊天技术:8k屏幕、4块GPU
  15. 【语义分割】3、用mmsegmentation训练自己的分割数据集
  16. 加油,我看好你 本题由擂主Wfox提供 -flag{bc57380e-9f8d-4b1e-8432-794b54b5625f}
  17. 高强度间歇训练(HIIT)
  18. Debezium系列之:使用Debezium接入PostgreSQL数据库数据到Kafka集群的详细技术文档
  19. 史上绝地反击,美式英语英文学习大全。美国英语最新词频表
  20. 一种实现人工智能程序自进化的概念原理

热门文章

  1. 指纹识别 python实现_Python还真当是无所不能!利用Python做指纹识别播报!闻所未闻!-站长资讯中心...
  2. len函数实例python_Python通过len函数返回对象长度
  3. 虚拟机一直安装程序正在启动服务器失败,安装使用Vmware出现的问题及解决方法...
  4. php Excel报表,Excel报表生成的方案 PHPExcel
  5. 341.扁平化嵌套列表迭代器
  6. 编写程序销毁一个单链表
  7. string和数值之间的转换
  8. centos中mysql操作命令_CentOS系统常用的MySQL操作命令总结
  9. 顺序容器和关联容器添加新元素方法详解
  10. idea的黄色感叹号之Spring Configuration Check (Please configura/setup Spring facet for modules)