如何格式化小数以显示为整数? [英] How do I format a decimal to display as a whole number?

查看:128
本文介绍了如何格式化小数以显示为整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的查询中,我有一个select语句,如下所示:



 SELECT 
CAST((mt.SampleTotal * 100)/(mt.PopulationTotal * 100.0)为数字(7,2))为'列%'





该语句返回。 14然而,我的用户希望看到答案返回为14(整数)。



有快速解决方法吗?



我尝试了什么:



我必须创建相当多的临时表来实现这一目标。理想情况下,此解决方案将是对select语句的修改。这是我到目前为止所尝试过的。

解决方案

删除底部的乘数?

  SELECT  CAST((mt.SampleTotal *  100 )/ mt.PopulationTotal  as   numeric  7  0 )) as  ' 列%'< /跨度> 


In my query I have a select statement that looks as follows:

SELECT 
 CAST((mt.SampleTotal * 100) / (mt.PopulationTotal * 100.0) as numeric(7,2)) as 'Column %'



That statement returns .14 My user however wants to see the answer returned as 14 (a whole number).

Is there a quick fix for this?

What I have tried:

I had to create quite a few temp tables to get this far. Ideally this solution would be a modification to select statement. This is what I've tried so far.

解决方案

Remove the multiplier at the bottom?

SELECT CAST((mt.SampleTotal * 100) / mt.PopulationTotal as numeric(7,0)) as 'Column %'


这篇关于如何格式化小数以显示为整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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