Reputation: 47
Hi I have the following table:
Doc | code | Qty | Next
5211386 | 91992 | 1 | 52183
5211386 | 91992 | 1 | 52182
I trying to figure out a way to group the records by the first two colums, sum the third and concat the last column to obtain something like:
Doc | code | Qty | Next
5211386 | 91992 | 2 | 52183-52182
Any help?
Upvotes: 2
Views: 3297
Reputation: 918
Sounds like you're looking for a group_concat like function found in MySQL. Check out Allen Browne's solution
SELECT Doc, code, Sum(Qty), ConcatRelated("[Next]","TableName",,,"-") as [Next]
FROM TableName
GROUP BY Doc, code
Upvotes: 3