CONCAT:连接字符串,CONCAT(55.00,’%’)->55.00%
truncate:处理小数点位数,truncate(10.1111,2)->10.11
统计sql
1 | select res.*, CONCAT(truncate((res.succ / res.`all`) * 100, 2), '%') as 'success rate' |
统计结果
USER_NO | TYPE | all | succ | fail | other | success rate |
---|---|---|---|---|---|---|
456 | 10 | 1 | 0 | 0 | 1 | 0.00% |
123 | 10 | 29 | 23 | 0 | 6 | 79.31% |