【四舍五入取整截取】

select round(54.56,0)

【向下取整截取】

SELECT FLOOR(54.56)

【向上取整截取】

 SELECT   CEILING(13.15)

--MSSQL取整函数的使用

--两个整数相除将截断小数部分 
select 3/4,4/3,5/3 
--结果 0,1,1 
 
--返回大于或等于所给数字表达式的最小整数 
SELECT CEILING(123.55), CEILING(123.45),CEILING(-123.45), CEILING(0.0) 
--结果 124,124,-123,0 
 -- www.2cto.com  
--四舍五入 round(a,b) -- 结果a 精确到小数点右 b位,或是左 -b位
select round(54.36,-2), round(54.36,-1),round(54.36,0), round(54.36,1),round(54.36,2) 
--结果 100.00,50.00,54.00,54.40,54.36 
 
---四舍五入 并转化为 整数 
select cast(round(56.361,0) as int),cast(round(56.561,0) as int) 
--结果 56,57 
 
--举例使用 
 
---两个整数相除 舍弃小数部分( 全部都向前进位) 
declare @dividend decimal(20,2), @divisor decimal(20,2) 
 
set @dividend=3 
set @divisor=4 
select CEILING(@dividend/@divisor) 
--结果 1 
 
set @dividend=4 
set @divisor=3 
select CEILING(@dividend/@divisor) 
--结果 2 
 
set @dividend=5 
set @divisor=3 
select CEILING(@dividend/@divisor) 
--结果 2

---两个整数相除 四舍五入到整数 
set @dividend=3 
set @divisor=4 
select cast(round(@dividend/@divisor,0) as int) 
--结果 1 
 
set @dividend=4 
set @divisor=3 
select cast(round(@dividend/@divisor,0) as int) 
--结果 1 
 
set @dividend=5 
set @divisor=3 
select cast(round(@dividend/@divisor,0) as int)

--结果 2

【四舍五入取整截取】

select round(54.56,0)

【向下取整截取】

SELECT FLOOR(54.56)

【向上取整截取】

 SELECT   CEILING(13.15) 

Sql 获取向上取整、向下取整、四舍五入取整的实例的更多相关文章

  1. JS中对小数取整的函数,向上(下),四舍五入取整

    1.丢弃小数部分,保留整数部分 js:parseInt(7/2) 2.向上取整,有小数就整数部分加1 js: Math.ceil(7/2) 3,四舍五入. js: Math.round(7/2) 4, ...

  2. SQL 向上取整、向下取整、四舍五入取整的实例!round、rounddown、roundup

    sql server ==================================================== [四舍五入取整截取] select round(54.56,0) === ...

  3. Sql Server 里的向上取整、向下取整、四舍五入取整

    ==================================================== [四舍五入取整截取] select round(54.56,0) ============== ...

  4. Sql Server 里的向上取整、向下取整、四舍五入取整的实例!

    http://blog.csdn.net/dxnn520/article/details/8454132 =============================================== ...

  5. Sql Server 向上取整、向下取整、四舍五入取整

    ==================================================== [四舍五入取整截取] select round(55.56,0) ============== ...

  6. SQLSERVER 数值 四舍五入取整 向上取整 向下取整

    [四舍五入取整截取] select round(54.56,0) [向下取整截取] SELECT floor(54.56) [向上取整截取]  SELECT   ceiling(13.15)

  7. PHP取整,四舍五入取整、向上取整、向下取整、小数截取

    PHP取整数函数常用的四种方法: 1.直接取整,舍弃小数,保留整数:intval(): 2.四舍五入取整:round(): 3.向上取整,有小数就加1:ceil(): 4.向下取整:floor(). ...

  8. 怎样对小数进行向上取整 / 向下取整 / 四舍五入 / 保留n位小数 / 生成随机数

    1. 向上取整使用: Math.ceil() Math.ceil(0.1); Math.ceil(1.9); 2. 向下取整使用: Math.floor() Math.floor(0.1); Math ...

  9. c++ 取整:四舍五入 向上取整 向下取整

    对于数据的取整是经常需要考虑的 现在总结如下 #include<iostream> #include<cmath> using namespace std; int main( ...

随机推荐

  1. linux下给网卡加VLAN标签和私网地址

    1.加载8021q协议 moprobe 8021q 2.安装必要的包 yum -y groupinstall base linux 3.添加私网地址(写到开机启动项) vconfig add bond ...

  2. php请求返回GeoJSON格式的数据

    <?php /* * Following code will list all the products */ // array for JSON response $response = ar ...

  3. JavaACOFramework的各个类介绍(part2 : Ant4AS类)

    package aco.ant; import java.util.ArrayList; import util.RouletteWheel;//引入轮盘类 import aco.ACO;//引入蚁群 ...

  4. JS高级程序设计 笔记

    1.instanceof 可以判断实例是否在某个对象的原型上: function A() { this.a = "a"; } function B() { this.b = &qu ...

  5. 特殊符号 && 和 ||

    一.值为false的情况 如果逻辑对象值为0,-0, null,undefined,false,"",NaN.那么值为false. 二.&& || 的 理解 1.& ...

  6. 关于equals、hashcode和集合类的小结

    一.首先明确一点:equals()方法和hashcode()方法是Object类里的方法. 查看源码可以知道,在Object类中equals(obj)方法直接返回的是  this == obj 的值. ...

  7. Codeforces 722D. Generating Sets

    D. Generating Sets time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. 微信iphone7、 ios10播放视频解决方案 2016.11.10

    2016.11.10日更新以下方法 微信最新出同层播放规范 即使是官方的也无法解决所有android手机的问题. 另外iphone 5 .5s 某些手机始终会弹出播放,请继续采用 “以下是老的解决办法 ...

  9. python走起之第十七话

    选择器 #id 概述 根据给定的ID匹配一个元素. 使用任何的元字符(如 !"#$%&'()*+,./:;<=>?@[\]^`{|}~)作为名称的文本部分, 它必须被两个 ...

  10. “static”引发的一个错误

    昨天晚上,舍友发来一个程序,先把代码贴上:  #include<stdio.h>#define N 20short bufferA[N]={1,2,3,4,5,6,7,8,9,10,11, ...