Я хотел бы добиться следующего:
из временной метки. Я хотел бы указать, где часть времени попадает под какой интервал, как.08:00:00 - 12:59:59, 13:00:00 - 17:59:59, 18:00:00 - 22:59:59 и т. Д. Вся идея обернута вокруг, и я хочу определить, в какое времяв день веб-сайт в основном посещается.Я использовал cast(timestamp as time)
, он не работает, я сделал select '2018-05-25 12:00:00'::time
, он извлекает время, но только когда он набирается в тексте, а не в имени столбца, я надеюсь использовать «предположим, что этот код работал»:
select timestamp::time between '08:00:00'::time and '12:59:59'
мое первоначальное решение было, что мой менеджер говорит, что это неправильно.
sum(case when cast(substring(split_part(event_date, ' ', 2),1,2) as int) in (23,00,01,02,03,04) then 1 else 0 end) as time_23_04,
sum(case when cast(substring(split_part(event_date, ' ', 2),1,2) as int) between 5 and 7 then 1 else 0 end) as time_05_07,
sum(case when cast(substring(split_part(event_date, ' ', 2),1,2) as int) between 8 and 12 then 1 else 0 end) as time_08_12,
sum(case when cast(substring(split_part(event_date, ' ', 2),1,2) as int) between 13 and 17 then 1 else 0 end) as time_13_17,
sum(case when cast(substring(split_part(event_date, ' ', 2),1,2) as int) between 18 and 22 then 1 else 0 end) as time_18_22