db.table替换为自己的表名,StartTime为date字段
select count(*),
(case floor((to_char(StartTime,‘mi‘))/15)
when 0 then to_char(StartTime,‘yyyy.mm.dd hh‘)||‘:00:00‘
when 1 then to_char(StartTime,‘yyyy.mm.dd hh‘)||‘:15:00‘
when 2 then to_char(StartTime,‘yyyy.mm.dd hh‘)||‘:30:00‘
when 3 then to_char(StartTime,‘yyyy.mm.dd hh‘)||‘:45:00‘
end) as StartTime
from db.table
group by StartTime
时间: 2024-10-25 19:30:16