sql按小时统计信息量

来源:互联网 发布:linux 搜索文件夹权限 编辑:程序博客网 时间:2024/05/16 15:07

select year(create_time),month(create_time),day(create_time),hour(create_time),count(1) all_count,
count(CASE WHEN (tlgcr.crawler_result = '1') THEN 1    ELSE    NULL    END    ) success_count,
count(CASE WHEN (tlgcr.crawler_result = '0') THEN 1    ELSE    NULL    END    ) fail_count,
count(CASE WHEN (tlgcr.crawler_result = '1') THEN 1    ELSE    NULL    END    )/count(1) succcess_rate,
count(CASE WHEN (tlgcr.crawler_result = '0') THEN 1    ELSE    NULL    END    )/count(1) fail_rate
 from t_log_gongshang_crawler_result tlgcr group by year(create_time),month(create_time),day(create_time),hour(create_time);
0 0