1.case when的用法

需求:将brand_type对应的数字翻译成品牌
select
case
when brand_type=1 then '荣威'
when brand_type=2 then '名爵'
when brand_type=4 then 'R标'
else brand_type
end as attr1
from tb
2.手机号加密

//第一种
replace(user_phone,substr(user_phone,4,4),'xxxx')
//第二种(md5函数)
在网上看到说的是,hive里面没有自带的md5函数,需要自己自定义udf,实现md5函数


3.cast(字段名 as 字段类型)
需求是得到float类型,但是原字段是decimal类型

select
cast(order_amount as float)
from tb
171



被折叠的 条评论
为什么被折叠?



