Objective is to make table unique at ID using group by , concat_ws and collect_list ,combining distinct values in one row.
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 03:45 AM
Objective is to make table unique at ID. Table structure is as in attached image.
Query used is :
select
ID,
concat_ws(' & ' , collect_list(Distinct Gender)) as Gender
from table
group by ID
It can be possible if we can order values within collect_list and then concat but I can't figure out how to do that.
@Hubert Dudek @Werner Stinckens @Aviral Bhardwaj @Hemanth A @Omkar G @Yogita Chavan @Gam Nguyen @Aman Sehgal @Ajay Pandey @pat @Hau Nguyen
Labels:
- Labels:
-
Collect_set
-
Distinct Values
-
Groupby
-
Table