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;
2条答案
按热度按时间wf82jlnq1#
使用条件聚合:
wfveoks02#
这也许对你有帮助,@john,如何用一个sql查询获得多个计数?它与聚合函数一起使用count,以便在一个查询中针对多个count函数。。