impala中的字符串拼接函數


impala中拼接字符串的函數:

 

concat(string a, string b...)
Purpose: Returns a single string representing all the argument values joined together.
Return type: string Usage notes: concat() and concat_ws() are appropriate for concatenating the values of multiple columns within the same row, while group_concat() joins together values from different rows.

select concat('aaa','vvv','234')
aaavvv234


concat_ws(string sep, string a, string b...)
CONCAT_WS() 代表 CONCAT With Separator 是CONCAT()的特殊形式。第一個參數是其它參數的分隔符。分隔符的位置放在要連接的兩個字符串之間。分隔符可以是一個字符串,也可以是其它參數。如果分隔符為 NULL,則結果為 NULL。函數會忽略任何分隔符參數后的 NULL 值。但是CONCAT_WS()不會忽略任何空字符串。 (然而會忽略所有的 NULL)。
SELECT CONCAT_WS(',','First name',NULL,'Last Name');

SELECT CONCAT_WS(',','First name','Last Name','NULL');
First name,Last Name,NULL
SELECT CONCAT_WS(',','First name','Last Name',NULL);
NULL

注意:null 和任何字符串拼接都是NUll


group_concat(string s [, string sep])
按照指定分隔符, 將多行記錄的 s 表達式結果拼接起來

select id,group_concat(name,'##') from (
select 1 as id,'zhangsan' as name
union all
select 1,'zhangshu'
union all
select 2,'wangwu'
union all
select 2,'wangsan'
union all
select 2,'wangbu'
) t group by id

 

 




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM