sql 一张表查询成功率
服务日志表
SFCG表示接口调用的状态码; 000为成功
查询:服务序号,该服务调用的总次数,调用成功率
SELECT
FW_XH,
COUNT(*) AS numberOfCalls,
CAST( sum(CASE WHEN SFCG = '000' THEN 1 ELSE 0 END) / CAST( COUNT(0) AS DECIMAL ( 6, 2 ) ) * 100 AS DECIMAL ( 10, 2 ) ) as successRate
FROM
tableName
WHERE
cjsj > '2021-08-20 15:00'
group by
FW_XH