MySQL如何通过sql查询数据的区间分布情况?

已邀请:

zkbhj - 凯冰科技站长

赞同来自:

select
count(case when time>=1 and time <=5 then id end)/20000*100 as '<=5s',
count(case when time>=6 and time <=15 then id end)/20000*100 as '6s~15s',
count(case when time>=16 and time <=30 then id end)/20000*100 as '16s~30s',
count(case when time>=31 and time <=60 then id end)/20000*100 as '31s~1min',
count(case when time>=61 and time <=120 then id end)/20000*100 as '1min~2min',
count(case when time>=121 and time <=300 then id end)/20000*100 as '1min~5min',
count(case when time>=301 and time <=600 then id end)/20000*100 as '5min~10min',
count(case when time>=601 and time <=900 then id end)/20000*100 as '10min~15min'
from zk_time

要回复问题请先登录注册