How to achieve the same column grouped hivesql string stitching it?
After grouping, in groups of strings together make a column effect is as follows:
You know, mosaic columns strings is not difficult, concat can be achieved, concat (col1, col2, col3) will be the first column, second row, third column character stitching up here do not do a demonstration.
But if you want a mosaic of characters? Xiao Bian is not met you, so ignorant of a force. Under the search, and I found a good use of the function
concat_ws
select id, concat_ws('_',collect_set(col1)) as concatcol1 from table group by id
After an unsuccessful try small series, so for a second function groupconcat
select id,group_concat(distinct(col1),'_') as concatcol1 from table group by id
Achieved within the group, stitching in the same column string.