SQL CASE WHEN

给 响应时间 划分区间

SELECT response_ms/1000 as response_sec ,
     CASE WHEN  response_ms/1000 <= 1 THEN '0~1s'
     WHEN response_ms/1000 > 1 AND response_ms/1000 <=10 THEN '1~2s'
     WHEN response_ms/1000 > 10 AND response_ms/1000 <=15 THEN '10~15s'
     WHEN response_ms/1000 > 15  THEN '15+s'
     ELSE 'UNKNOWN' END AS interval_response
FROM table_a
1
2
3
4
5
6
7

使用 TRIM() 删除 CASE WHEN 新生成字段的 三个空格

reference

访客IP ,您的网络 访问优先

本站是个人博客,书写大数据、数据科学等领域的原创学习记录,转载请注明出处

本站运行于 腾讯云 腾讯云