Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys, I'm wondering how to do the following thing :
I have a table like this :
| user_id | user |
|---|---|
| 1 | U1 |
| 2 | U2 |
| 3 | U3 |
| 4 | U4 |
| 5 | U5 |
| 6 | U6 |
And I would like to concat the values in rows by three as the following :
| concats_users |
|---|
| U1,U2,U3 |
| U4,U5,U6 |
How could you do that??
Many thanks in advance.
Cheers!
Not sure what rule you want to use for the grouping, but this could be a solution:
Load
Concat(distinct user_id,',') as concats_user_ids,
Concat(distinct user,',') as concats_users,
Group
group by Group;
Load user_id, user, div(user_id-1,3) as Group
inline
[user_id,user
1,U1
2,U2
3,U3
4,U4
5,U5
6,U6];
HIC