0

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

1 Answer 1

1
select id_boss, 
       min(id_child) as id_child1,
       max(id_child) as id_child2
from your_table
group by id_boss
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.