背景:離線的數據中有時間戳,要求按五分鍾規划為一組00:00 - 23:55
1.cast(date_format(t1.order_end_time,'HH') as string)把小時拿出來
2.(floor(date_format(t1.order_end_time,'mm')/5 )*5) as string 把分鍾數除5,24/5=4.8。再向下取整=4。再乘5=20。
3.case when判斷如果結果是0就得00,5就得05
4.最后concat_ws拼接小時和分鍾
concat_ws(':',cast(date_format(t1.order_end_time,'HH') as string)
,case when cast((floor(date_format(t1.order_end_time,'mm')/5 )*5) as string) = '0' then '00'
when cast((floor(date_format(t1.order_end_time,'mm')/5 )*5) as string) = '5' then '05'
else cast((floor(date_format(t1.order_end_time,'mm')/5 )*5) as string) end) as '分鍾段'