Reputation: 79
Following data I have:
Table1
ID Name Qty Len Wid
1 Name1 1 100 200
2 Name1 3 100 200
3 Name2 2 200 300
4 Name2 1 200 300
5 Name2 2 200 300
Result I need:
Name SumQty Len Wid JoinedId
Name1 4 100 200 1,2
Name2 5 200 300 3,4,5
With this sql I get sumQty
select Name, Len, Wid, SUM(Qyt) as SumQty
from Table1
group by 1,2,3
How to establish, which records are grouped together and get their IDs comma separated in one string?
I'm using firebird sql server.
Upvotes: 2
Views: 81
Reputation: 48207
For firebird 2.1 you can use LIST
LIST ([ALL | DISTINCT] expression [, separator])
select Name, Len, Wid, SUM(Qyt) as SumQty, LIST(ID)
from Table1
group by 1,2,3
Upvotes: 3