hive sql 计算订单率,比值结果为小数最终变成 0E-4~0E-5
-- 解决方式
cast(4/100000*1.0 as decimal(16,4))
hive sql 过滤条件中,限定某个字段不为某个值时
-- 使用 <>
例如:
select *
from db_europe.switzerland_table
where 1 = 1
and city <> 'beijing' ;
hive 中 获取 map<string,string> 类型字段中的某个 key,value 对value
kv[content]
将hive中字符串中的字符大写转小写
select lower('abSEd')
-- 执行结果 absed
时间格式转化
from_unixtime(unix_timestamp('20231204','yyyyMMdd'),'yyyy-MM-dd')
-- 将 20231204 格式的日期转化为 2023-12-04 格式
字符串拼接函数
select concat( cast( cast(0.86425*100 as decimal(9,2)) as string), '%') ;
-- 将小数以百分比的形式进行展示
使用 case when 为某条数据打标签
CASE
WHEN distinct_id REGEXP '^\\d+$'
THEN 1
ELSE 0
-- 1 是数字字符串,0不是数字字符串