hive case when then 多条件

 

hive中的case when,有多个条件时,可以这样写:

select substr(key,13,2),
case when birthday<'1968' then '50up'
when birthday<'1978' then '40-50'
when birthday<'1983' then '35-40'
when birthday<'1988' then '30-35'
when birthday<'1992' then '26-30'
when birthday<'1998' then '20-25'
else 'other' end,
count(1)
from hiveTable
group by substr(key,13,2),
case when birthday<'1968' then '50up'
when birthday<'1978' then '40-50'
when birthday<'1983' then '35-40'
when birthday<'1988' then '30-35'
when birthday<'1992' then '26-30'
when birthday<'1998' then '20-25'
else 'other' end

 

posted @ 2020-08-25 10:46  香山上的麻雀  阅读(3277)  评论(1)    收藏  举报