【四舍五入取整截取】

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. psr的规范

    基本代码规范 本篇规范制定了代码基本元素的相关标准, 以确保共享的PHP代码间具有较高程度的技术互通性. 关键词 "必须"("MUST")."一定不可 ...

  2. Cheatsheet: 2016 10.01 ~ 10.31

    Docker Introduction to Docker Monitoring Database MongoDB: The Good, The Bad, and The Ugly Web 4 Key ...

  3. 理解ASP.NET MVC中的HTML Helpers

    01 内联Html Helpers @helper listItems(string[] items) { <ol> @foreach (var item in items) { < ...

  4. dsp28377控制DM9000收发数据

    首先感谢上一篇转载文章的作者给出的参考,下面是一些自己在调试过程中的一些步骤: 首先把代码贴上来: //------------------------------------------------ ...

  5. Java 集合 - HashSet

    一.源码解析 public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable ...

  6. mySQL 50个查询系列

    http://bubufx.com/detail-1749088.html http://www.jb51.net/article/67932.htm Student(S#,Sname,Sage,Ss ...

  7. zend studio 10破解/汉化

    http://blog.csdn.net/qq1355541448/article/details/16807429

  8. MVC使用Membership配置

    MVC的权限管理,环境是MVC4.5,SQL Server2008 修改前 Web.config文件: <system.web> <authentication mode=" ...

  9. python操作csv和excel文件

    1.操作csv文件 1).读取文件 import csv f=open("test.csv",'r') t_text=csv.reader(f) for t,i in t_text ...

  10. ssh 登录

    一.ssh登录过程 在实际开发中,经常使用ssh进行远程登录.ssh 登录到远程主机的过程包括: 版本号协商 密钥和算法协商 认证 交互 1.1 版本号协商阶段 (1) 服务端打开22端口(也可以为了 ...