I am not sure what database technology you are working on however this can be achieved pretty easily using group_concat feature in mysql
mysql>
mysql> create table t1(id int,value int);
Query OK, 0 rows affected (0.03 sec)
mysql>
mysql>
mysql> insert into t1 values(1,21),(1,22),(1,23),(2,24);
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql>
mysql>
mysql>
mysql> select * from t1;
+------+-------+
| id | value |
+------+-------+
| 1 | 21 |
| 1 | 22 |
| 1 | 23 |
| 2 | 24 |
+------+-------+
4 rows in set (0.00 sec)
mysql>
mysql>
mysql>
mysql> select id,group_concat(value) from t1 group by id;
+------+---------------------+
| id | group_concat(value) |
+------+---------------------+
| 1 | 21,22,23 |
| 2 | 24 |
+------+---------------------+
2 rows in set (0.00 sec)