如何查询查询结果的字母顺序?
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
答案 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