MySql计算百分比

计算百分比


@top 代表 分子, @bot 代表分母

set @top = 1;
set @bot = 3;

SELECT CONCAT(ROUND( @top/ @bot * 100, 2), " %");
-- 33.33 %

SELECT ROUND( @top/ @bot * 100, 1);
-- 33.3

SELECT ROUND( @top/ @bot * 100), round(10/3, 3);
-- 33   3.333

猜你喜欢

转载自blog.csdn.net/ai_shuyingzhixia/article/details/80379743