concat_ws(合并时的分隔符,合并字段1,字段2。。。)
collect_set(字段):根据某个字段分组后,把分在一组的数据合并在一起,默认分隔符','
eg:
select jzad,os_type,concat_ws(',',collect_set(host))
from
(select jzad,os_type,host,count(*),row_number() over(partition by jzad,os_type order by cast(count(*) as int) desc) rank
from fengshang_1387ad_top10host_zqm group by jzad,os_type,host
) a where rank<=10
group by jzad,os_type
本文介绍了一种使用SQL进行数据合并的方法,具体地,通过concat_ws和collect_set函数将同一组内的记录合并为一条记录,并以逗号作为默认分隔符。此方法适用于需要对分组数据进行整合的场景,如广告平台中的主机地址汇总等。
1398

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



