百分比值到2位小数 [英] percentage value to 2 decimal places

查看:72
本文介绍了百分比值到2位小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个按钮后面的SQL语句中有以下内容

在ac#表单上。



 SELECT ...(@ total1- @ total2)/ @ total1 * 100 AS [%],... 



但它产生11位小数。

如何将结果限制为1或2个小数位?

尝试过



 CONVERT(DECIMAL( 8  2 

解决方案

尝试:

  SELECT  ROUND(( @ total1- @ total2)/(@ total1 * 100), 2  AS  [%] 


I have the following inside an SQL statement behind a button
on a c# form.

SELECT ... (@total1-@total2)/@total1*100 AS [%],...


but it is producing 11 decimal places.
How to restrict the result to just 1 or 2 decimal places ?
Have tried with

CONVERT(DECIMAL(8,2)

解决方案

Try:

SELECT ROUND((@total1-@total2)/(@total1*100), 2) AS [%]


这篇关于百分比值到2位小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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