SQL Fundamentals || Single-Row Functions || 数字函数number functions
SQL Fundamentals || Oracle SQL语言
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 |
SQL Fundamentals || Single-Row Functions || 数字函数number functions的更多相关文章
- SQL Fundamentals || Single-Row Functions || 字符函数 character functions
SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使 ...
- SQL Fundamentals || Single-Row Functions || 日期函数date functions
SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使 ...
- Oracle Single-Row Functions(单行函数)——NULL-Related Functions
参考资料:http://docs.oracle.com/database/122/SQLRF/Functions.htm#SQLRF006 Single-row functions return a ...
- SQL Fundamentals || Single-Row Functions || 转换函数 Conversion function
SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使 ...
- SQL Fundamentals: Using Single-Row Functions to Customize Output使用单行函数自定义输出
SQL Fundamentals || Oracle SQL语言 DUAL is a public table that you can use to view results from functi ...
- SQL Fundamentals || Single-Row Functions || 通用函数 General function || (NVL,NVL2,NULLIF,DECODE,CASE,COALESCE)
SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使用单 ...
- SQL Fundamentals || Oracle SQL语言
对于SQL语言,有两个组成部分: DML(data manipulation language) 它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样,这4条命令是用来对数据 ...
- 微软BI 之SSIS 系列 - Execute SQL Task 中的 Single Row 与 Full Result Set 的处理技巧
开篇介绍 Execute SQL Task 这个控件在微软BI ETL 项目中使用的频率还是非常高的,也是大部分入门 SSIS 初学者最早接触到的几个控制流控件. 我们通常使用 Execute SQL ...
- 高精度运算专题-输出函数与字符串转数字函数(Output function and the string to number function)
输出函数:这个函数别看它小,但浓缩的都是精华啊 作用:对于高精度的数组进行倒序输出 思路:首先从被传入的数组第一位开始,一直往前扫输出就可以了(i--) 注释:因为每个数组的第一位是用来存储这个数组的 ...
随机推荐
- css counter的使用方法
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Python 统计代码量
#统计代码量,显示离10W行代码还有多远 #递归搜索各个文件夹 #显示各个类型的源文件和源代码数量 #显示总行数与百分比 import os import easygui as g #查找文件 def ...
- pgpool-II 的使用
1.pgpool-II的概念 pgpool-II 是一个位于 PostgreSQL 服务器和 PostgreSQL 数据库客户端之间的中间件,它提供以下功能: 连接池 pgpool-II 保持已经连接 ...
- Kafka producer介绍
Kafka 0.9版本正式使用Java版本的producer替换了原Scala版本的producer.本文着重讨论新版本producer的设计原理以及基本的使用方法. 新版本Producer 首先明确 ...
- C++ template —— template metaprogram(九)
metaprogramming含有“对一个程序进行编程”的意思.换句话说,编程系统将会执行我们所写的代码,来生成新的代码,而这些新代码才真正实现了我们所期望的功能.通常而言,metaprogrammi ...
- 使用API函数EnumWindows()枚举顶层窗口
http://simpleease.blog.163.com/blog/static/1596085820052770290/ 要枚举Windows当前所有打开的顶层窗口,可使用Windows A ...
- Objective-C官方文档 协议
版权声明:原创作品,谢绝转载!否则将追究法律责任. 在现实生活中,当处理某一情况的时候人们往往遵循严格的程序.执法人员他们在打官司的收集证据和询问的时候一定要遵守协议. 在面向对象的语言中,最重要的是 ...
- 关于 CommonJS AMD CMD UMD 规范的差异总结(转)
根据CommonJS规范,一个单独的文件就是一个模块.每一个模块都是一个单独的作用域,也就是说,在一个文件定义的变量(还包括函数和类),都是私有的,对其他文件是不可见的. // foo.js var ...
- Android单例模式
Android设计模式系列(3)--SDK源码之单例模式:http://www.cnblogs.com/qianxudetianxia/archive/2011/08/07/2130306.html ...
- Oracle 学习之触发器
1. 触发器简介 触发器是存储在数据库服务器中的程序单元,当一个表或一个视图被改变,或者数据库发生某些事件时,Oracle会自动触发触发器,并执行触发器中的代码.只有在触发器中定义的事件发生时,触发器 ...