JOIN LINES in BigSQL where PRODUCTs are the SAME

58 Views Asked by At

I am having this sample table below

+---------+----------------------+
| PRODUCT | TYPE                 |
+---------+----------------------+
| WIN 10  | Home                 |
+---------+----------------------+
| WIN 10  | Pro                  |
+---------+----------------------+
| WIN 10  | Pro for Workstations |
+---------+----------------------+
| Linux   | Ubuntu               |
+---------+----------------------+
| Linux   | Red Hat              |
+---------+----------------------+
| Linux   | Fedora               |
+---------+----------------------+

I would like to change it (transpose) to have result like seen below using MySQL

+---------+-------------------------------+
| PRODUCT | TYPE                          |
+---------+-------------------------------+
| WIN 10  | Home,Pro,Pro for Workstations |
+---------+-------------------------------+
| Linux   | Ubuntu,Red Hat,Fedora         |
+---------+-------------------------------+

Could you please help me with that? I have tried everything I could using this forum and I am not able to get the result I need, thank you very much for your help

1

There are 1 best solutions below

2
ScaisEdge On BEST ANSWER

In mysql You could use group_concat

select product, group_concat(type)
from my_table 
group by product 

or with order by

select product, group_concat(type order by type)
from my_table 
group by product 

for BigSQL the equivalent function should be LISTAGG(type)