如何在蜂巢中对concat_ws(';',collect_set(name))结果进行排序?

时间:2019-07-11 10:56:43

标签: arrays hadoop hive hiveql

如何查询查询结果的字母顺序?

select b6.S_Architect as S_Architect 
  from applications a
       left outer join
       (select id,concat_ws(';' , collect_set(name)) as S_Architect 
          from solution_architect
         group by parentcontentid
       ) b6 on a.id = b6.Id;

预期结果

Andy;Bravo;Cindy;David

实际结果

Cindy;Bravo;David;Andy

1 个答案:

答案 0 :(得分:1)

使用sort_array

select concat_ws('\073',sort_array(collect_set(name))) from (select stack(4,'Cindy','Bravo','David','Andy') as name) s;

返回:

OK
Andy;Bravo;Cindy;David