- case when
- MySQL
select case gender when 0 then 'Male'
when 1 then 'Female'
else 'other' end as gender
from table
;
- Hive
select case when gender = 0 then 'Male'
when gender = 1 then 'Female'
else 'other' end as gender
from table
where dt > 0 --针对所有分区,全表扫描
;
- from_unixtime() 时间戳转成日期时间
- MySQL
select ptime, from_uni