select id_boss,
min(id_child) as id_child1,
max(id_child) as id_child2
from your_table
group by id_boss
Sqlite : How to merge column into one row select
-
20-07-2023 - |
Domanda
i'm working with sqlite right now,
i want to merging some column that have a same parent id but different child id each every group;
this is my table;
+---------+----------+
|id_boss | id_child |
+---------+----------+
| 2 | 1 |
| 2 | 9 |
| 5 | 3 |
| 5 | 4 |
| 6 | 7 |
| 6 | 8 |
+---------+----------+
and i'm looking a way to combine column id_child
and the result would be something like this :
+---------+-----------+-----------+
|id_boss | id_child1 | id_child2 |
+---------+-----------+-----------+
| 2 | 1 | 9 |
| 5 | 3 | 4 |
| 6 | 7 | 8 |
+---------+-----------+-----------+
id_child first row group id_boss is in id_child1 and second row group id_boss is in id_child2
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow