1,不带小数点的百分比
SELECT CONCAT(ROUND(errorTable.errorCount / totalTable.totalCount * 100),‘‘,‘%‘) FROM (SELECT COUNT(*) AS totalCount FROM dw_audit WHERE data_level = #{dataLevel} AND task_type = #{taskType}) AS totalTable, (SELECT COUNT(*) AS errorCount FROM dw_audit WHERE data_level = #{dataLevel} AND task_type = #{taskType} AND task_state = #{taskState}) AS errorTable
2,带小数点的百分比
CONCAT(ROUND(a.cnt / b.cntSum * 100, 2),‘‘,‘%‘)