在产品相同的 BigSQL 中加入行
JOIN LINES in BigSQL where PRODUCTs are the SAME
下面有这个示例table
+---------+----------------------+
| PRODUCT | TYPE |
+---------+----------------------+
| WIN 10 | Home |
+---------+----------------------+
| WIN 10 | Pro |
+---------+----------------------+
| WIN 10 | Pro for Workstations |
+---------+----------------------+
| Linux | Ubuntu |
+---------+----------------------+
| Linux | Red Hat |
+---------+----------------------+
| Linux | Fedora |
+---------+----------------------+
我想使用 MySQL
对其进行更改(转置)以获得如下所示的结果
+---------+-------------------------------+
| PRODUCT | TYPE |
+---------+-------------------------------+
| WIN 10 | Home,Pro,Pro for Workstations |
+---------+-------------------------------+
| Linux | Ubuntu,Red Hat,Fedora |
+---------+-------------------------------+
你能帮我一下吗?我已经尝试了所有我可以使用这个论坛的方法,但我无法得到我需要的结果,非常感谢你的帮助
在 mysql 你可以使用 group_concat
select product, group_concat(type)
from my_table
group by product
或按
订购
select product, group_concat(type order by type)
from my_table
group by product
对于 BigSQL,等效函数应该是 LISTAGG(type)
下面有这个示例table
+---------+----------------------+
| PRODUCT | TYPE |
+---------+----------------------+
| WIN 10 | Home |
+---------+----------------------+
| WIN 10 | Pro |
+---------+----------------------+
| WIN 10 | Pro for Workstations |
+---------+----------------------+
| Linux | Ubuntu |
+---------+----------------------+
| Linux | Red Hat |
+---------+----------------------+
| Linux | Fedora |
+---------+----------------------+
我想使用 MySQL
对其进行更改(转置)以获得如下所示的结果+---------+-------------------------------+
| PRODUCT | TYPE |
+---------+-------------------------------+
| WIN 10 | Home,Pro,Pro for Workstations |
+---------+-------------------------------+
| Linux | Ubuntu,Red Hat,Fedora |
+---------+-------------------------------+
你能帮我一下吗?我已经尝试了所有我可以使用这个论坛的方法,但我无法得到我需要的结果,非常感谢你的帮助
在 mysql 你可以使用 group_concat
select product, group_concat(type)
from my_table
group by product
或按
订购select product, group_concat(type order by type)
from my_table
group by product
对于 BigSQL,等效函数应该是 LISTAGG(type)