我有一个像这样的Hive表:
create table my_table
(
my_timestamp String
)
my_timestamp的格式为YYYY-MM-DD HH:MM:SS
。我需要将其归类为以下内容:
一种选择是将my_timestamp转换为unix_timestamp()
,为清晨,早晨等创建另一个unix_timestamp()
,然后减去2 unix_timestamps()
以对其进行分类。
我想知道是否有人能想到更简单的方法来做到这一点。任何帮助表示赞赏。
提前致谢。
答案 0 :(得分:0)
select
case floor(hour(my_timestamp) / 3)
when 2 then 'Early Morning'
when 3 then 'Morning'
when 4 then 'Afternoon'
when 5 then 'Evening'
else 'Night'
done
from my_table