mysql - SQL : return percentage without decimal place

标签 mysql

快速提问;有没有办法在 select 语句上应用数字类型?

示例用法

select (t1.f_count / (select count(*) from utb where user_id = 1))*100 as ratio

我需要这个来返回 60 而不是 60.0000

最佳答案

尝试

select ROUND((t1.f_count / (select count(*) from utb where user_id = 1))*100) as ratio

关于mysql - SQL : return percentage without decimal place,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1395619/

相关文章:

php - 覆盖持久性 :loadAll in EntityRepository

android - 上传图像文件到服务器

mysql - Electron 桌面应用程序 : Using mysql data in a component with Angular2 front end

MySQL 将一个表中的值连接到另一个表的记录中

mysql - "SELECT ... LOCK IN SHARE MODE"和 "SELECT ... FOR UPDATE"是否必须位于事务内部?

php 如果 AND mysql 为空

mysql - 在子日期之间的父日期之间加入自身

MySQL/玛丽亚数据库 : create a pivot table view

mysql - 无论如何,返回 IN 值的默认结果

mysql - 使用 GROUP BY 仅对某些行进行分组