带有百分比标准的MySQL百分比计算

时间:2018-10-08 13:04:11

标签: mysql

我有以下代码将查询我的数据库,该数据库将返回> 50的延迟并显示总延迟,然后将结果显示为百分比

  SELECT
        COUNT(CASE WHEN CAST(Latency As Signed) > 50 THEN 1 END) AS latency,
        COUNT(CASE WHEN CAST(Latency As Signed) > 0  THEN 1 END) AS total,
        100.0 * COUNT(CASE WHEN CAST(Latency As Signed) > 50 THEN 1 END) /
                 COUNT(CASE WHEN CAST(Latency As Signed) > 0  THEN 1 END) AS 
                 percentage
        FROM table
        WHERE date = 20180701;

现在是我的问题-是否可以仅显示大于10%的百分比,而不显示所有结果? IF语句会成为起点吗?

0 个答案:

没有答案