1.PG数据库按照30分钟时间片统计数据
select
t.syscode,
to_timestamp(concat (to_char(t.time, 'yyyy-mm-dd HH24'), ':',
FLOOR(date_part('minute', t.time) / 30)* 30), 'yyyy-mm-dd HH24:MI') as stat_at,
count(1) as count
from volume t
where t.time BETWEEN to_timestamp('2022-03-09 00:00:00','yyyy-MM-dd hh24:mi:ss') and to_timestamp('2022-03-09 23:59:59','yyyy-MM-dd hh24:mi:ss')
group by t.syscode,stat_at
order by t.syscode,stat_at