SQL Server中的舍入函数 [英] Round function in sql server

查看:120
本文介绍了SQL Server中的舍入函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要四舍五入.

例如,如果该数字导致2333.7


应用于2333.7之后,应该在2334中给出结果.


请帮忙 .我使用round(2333.7,0)将导致2333我需要2334

hi i need to round the number.

for example if the number resulted in 2333.7


and after applied round to 2333.7 it should give result in 2334.


please help . i used round(2333.7,0) it will result 2333 i need 2334

推荐答案

Um.
我刚试过:
Um.
I just tried it:
SELECT ROUND(2333.7, 0)As '0.7', ROUND (2333.4,0) as '0.4'


结果:


The results:

0.7	0.4
2334.0	2333.0


所以我会检查我的输入是否是你...

[edit] XML代码块从何而来? -OriginalGriff [/edit]


So I would check my inputs if I was you...

[edit]Where did the XML code block come form? - OriginalGriff[/edit]


我也尝试过,语法没问题.
它正在工作

无论如何,您也可以创建自己的函数
I have also tried it, no problem in your syntax.
it is working

anyway you can also create your own function


可能是您想要的.

May be you want this.

select convert(int,round(2333.49,0))as '2333.49',convert(int,round(2333.50,0))as '2333.50'



结果是:




Result is:


2333.49  2333.50
 2333	  2334




这将对您有帮助




This will be help properly


这篇关于SQL Server中的舍入函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆