sql中向下取整怎么取_Sql 获取向上取整、向下取整、四舍五入取整
【四舍五入取整截取】 select round(54.6,0) 返回55
【向下取整截取】 select floor(54.6) 返回54
【向上取整截取】 select ceiling(54.3) 返回55
--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中向下取整怎么取_Sql 获取向上取整、向下取整、四舍五入取整相关推荐
- sql中向下取整怎么取_Sql 获取向上取整、向下取整、四舍五入取整的实例
[四舍五入取整截取] select round(54.56,0) [向下取整截取] SELECT FLOOR(54.56) [向上取整截取] SELECT CEILING(13.15) --MSS ...
- mysql计算结果取整_Sql 获取向上取整、向下取整、四舍五入取整的实例(转)
[四舍五入取整截取] select round(54.56,0) [向下取整截取] SELECT FLOOR(54.56) [向上取整截取] SELECT CEILING(13.15) --MSS ...
- html中数值如何自动取整,excel四舍五入取整函数
excel 四舍五入取整的函数怎么弄? EXCEL四舍五入函数大全(一)round函数(二)rounddown函数(三)roundup函数(四)floor函数(五)ceiling函数(六)even函数 ...
- java 凑整_Java语言中的取整运算(包括截尾取整,四舍五入,凑整)? – 日记
import java.math.BigDecimal; import java.text.DecimalFormat; public class TestGetInt{ public static ...
- java四舍五入取整_java取整和java四舍五入方法
import java.math.BigDecimal; import java.text.DecimalFormat; public class TestGetInt{ public static ...
- SQL中的DISTINCT作用是什么?
但distinct的副作用是可能会在结果集中合并在select子句中未列出的字段上不同而在select子句中列出的字段上完全相同的记录 2009年11月02日 星期一 9:53 A.M. 它的作用是: ...
- 【转】面向对象之多态(向上转型与向下转型)
转:https://blog.csdn.net/qq_31655965/article/details/54746235. 多态,大概每个人都知道.但是,又有几个人真的理解什么是多态.多态有哪些细节呢 ...
- sql中向下取整怎么取_SQL中的取整函数、取小数
取整函数: 1.trunc(value,precision)按精度(precision)截取某个数字,不进行舍入操作. 返回截尾到y位小数的x值:trunc(x,[y]): select trunc( ...
- sql中向下取整怎么取_Sql Server 里的向上取整、向下取整、四舍五入取整的实例!...
==================================================== [四舍五入取整截取] select round(54.56,0) ============== ...
最新文章
- 【网站汇总】论文相关
- webview 加载php页面内容,WebView加载优化的方法介绍
- Linux c之函数手册
- 关于源文件用不同的编码方式编写,会导致执行结果不一样的现象及解决方法
- linux 当前用户执行定时任务
- 全网最细之static关键字讲解
- 线性表之简介及顺序表
- 网上收集总结一下mssql( 部分)
- python获取灰度图边界
- 将多个Excel文件合并为一个(实测有效)
- 2019年上半年软件设计师上午真题及答案解析
- ios app真机测试到上架App Store详细教程-必看
- 架构师米洛:你不经意的职场坏姿势会损坏你的身体
- PHP写的二维码签到,大家支持一下吧!
- Imazing2023免费版苹果手机iOS数据管理软件
- 三国志战略版:不接受反驳的全服最强五虎盾
- java图形打字机_Android模仿打字机效果的自定义View实现
- 北京住房公积金转杭州相关信息的整理,个人整理
- c语言程序无法打开文件,C语言fopen()总是提示无法正常打开文件
- 系统的软中断CPU使用率升高,该怎么办?