简体   繁体   English

四舍五入到最接近的百分比

[英]rounding to nearest percentage

If I have a formula such as如果我有一个公式,例如

count(s.listing_id) / count(a.listing_id) * 100

and I want to round to the nearest whole percentage,我想四舍五入到最接近的整数百分比,

would ROUND(count(s.listing_id) / count(a.listing_id) * 100),1) work?

as in if the value is .03881 should be 39?如果值是 .03881 应该是 39?

ROUND( count(s.listing_id) / count(a.listing_id) * 100 ) rounds to a whole number. ROUND( count(s.listing_id) / count(a.listing_id) * 100 )入为整数。

ref: the manual参考: 手册

Try adding more brackets.尝试添加更多括号。 Your formula still technically works in the way of PEDMAS, but this will future proof it.你的公式在技术上仍然以 PEDMAS 的方式工作,但这将在未来证明它。

ROUND(((count(s.listing_id) / count(a.listing_id)) * 100)),0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 四舍五入到最接近的.49或.99 - Rounding up to the nearest .49 or .99 价格舍入到最接近的5c - Price Rounding to nearest 5c 在php / mysql中将时间舍入到最接近的15分钟 - rounding time to the nearest 15 minutes in php/mysql 使用PHP和MySQL将DateTime值舍入到最近的小时 - Rounding DateTime Value to Nearest Hour with PHP and MySQL 使用 MySQL 将价格四舍五入到最接近的 95 便士 - Rounding up price with MySQL to the nearest 95p SQL Server 2008,将十进制值转换为百分比而不舍入? - SQL Server 2008, Convert decimal value to percentage without rounding? 查找最接近的百分比匹配2个字符串,然后返回下一个最接近的字符串 - Finding nearest percentage match to 2 strings, and returning next closest 将MySQL日期四舍五入到最接近的时间间隔,不受夏时制更改的影响 - Rounding MySQL dates to nearest interval without being affected by Daylight saving changes MYSQL 使用 TIME_FORMAT 将时间四舍五入到最近的小时,12 小时,但错误地将 AM 应用于所有内容 - MYSQL time rounding to nearest hour using TIME_FORMAT, 12 hour but incorrectly applies AM to everything SQL通过将列舍入为最接近的值,基于两列返回不同的行 - SQL Return distinct rows based on two columns by rounding column to nearest value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM