mysql常用算法积累


1、mysql计算百分比

使用sum函数,如下:

SELECT
COUNT( * ) AS 总数,
SUM( CASE WHEN `匹配情况` = 1 THEN 1 ELSE 0 END ) AS 总匹配数,
SUM( CASE WHEN `匹配情况` = 1 THEN 1 ELSE 0 END ) / COUNT( * ) * 100 总准确率,
SUM( CASE WHEN `投诉回复` = "无线" THEN 1 ELSE 0 END ) AS 投诉回复无线数,
SUM( CASE WHEN `匹配情况` = 1 THEN 1 ELSE 0 END ) / SUM( CASE WHEN `投诉回复` = "无线" THEN 1 ELSE 0 END ) AS 投诉回复无线准确率 
FROM

complaint_list;


你可能感兴趣的:(算法,数据库,大数据)