作者:帝·姬 | 来源:互联网 | 2023-10-14 16:53
round( 字段 / 字段 , 保留小数位数)
注意: COUNT(p.id)/c.sum 计算时,不能使用别名代替,否则报错(全部数学运算都是)
实例:
select city,
count(*) as '总职位数',
count(if (industryField like '%电子商务%',industryField,NULL)) as '电商职位数' ,
ROUND(count(if (industryField like '%电子商务%',industryField,NULL))/count(*),3) as proportion
from dataanalyst
group by city
having count(if (industryField like '%电子商务%',industryField,NULL))>30
order by '电商职位数'
引用