本文主要是介绍hive-去字符串前导0,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
hive-去字符串前导0
- leading:去掉字段串前的0
- TRAILING:去掉字段串后的0
- BOTH:去掉字段串前后的0
0的数量可以是不确定个数,也可以用这种方法去掉某些字符前缀后缀
SELECT a,trim(leading '0'FROM a) AS c1,trim(BOTH '0'FROM a) AS c2,trim(TRAILING '0'FROM a) AS c3
FROM (SELECT '010100100' AS aUNION ALLSELECT '10100100' AS aUNION ALLSELECT '0000010100100' AS aUNION ALLSELECT '00000a0100100' AS a) t
输出结果
a c1 c2 c3
00000a0100100 a0100100 a01001 00000a01001
0000010100100 10100100 101001 00000101001
010100100 10100100 101001 0101001
10100100 10100100 101001 101001
这篇关于hive-去字符串前导0的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!