cast 函数:
类型转换函数,cast(kbcount as int);
case when:
条件判断,case when kbcount is not null and cast(kbcount as int) >= cast(patch_count as int) then '1' else '0' end as isinstalled ;
语法:方法1
(
case sex
when '1' then '男'
when '2' then '女'
else '未知'
end
) as 性别
方法2
case
when sex='1' then '男'
when sex='2' then '女'
else '未知'
end as 性别
from_unixtime:将unix时间戳转化为制定格式的时间
from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') as xdsp_last_update_time
lcase() :将字段的值转换为小写
lcase(t.info_iot_name)
hive collect_set: 可以得到分组后,其他合并元素的制定位置的值作为去重后的值。
表明:user
id , name, url
1 shao www
1 shao1 www1
2 zhi www
2 zhi1 www.ee
2 zhi2 www.2323
3 qi www.eere
3 qi2 www.urr
想要得到:
id , name, url
1 shao www
2 zhi www
3 qi www.eere
sql实现:方法1
select id ,collect_set(name)[0],collect_set(url)[0]
from user
group by id;
方法2:
select id ,max(name),max(url)
from user
group by id;
字符串max:字符串按照字母A-Z,越往后值越大
汉字按照全拼字母排,第一个字母相同则看第二个
concat() : 将两个或者多个字符串连接起来,如果有任何一个参数为null,则返回值为null
a.os_version like concat('%','2012r2','%')
concat_ws(): 以第一个参数为分隔符,将其他参数连起来
concat_ws('.',os_version_main,os_version_sp,os_version_bit,os_version_sub)