I have some sql which is grouping data to summarize it.
Its basically a list of locations, items and quantities.
SELECT ItemCode, SUM(Qty) AS Qty
FROM Putaway
GROUP BY ItemCode
Which is working as expected, giving a summary of the results.
ItemCode - Qty
AAAA - 1
BBBB - 2
CCCC - 3
But I have been asked to give a list of locations for each of the items as well.
So basically I want to Generate the results to be like:
ItemCode - Qty - Locations
AAAA - 1 - A1
BBBB - 2 - B1, B2
CCCC - 3 - B5, B6, B7
If I do the obvious - and just Add [Location] to the SELECT and Group By Then its giving me 2 rows for BBBB, 3 for CCCC etc. (Exactly as it should be, but not how I want it)
So, since there are multiple rows for each item in the table - how can I summarize it and combine the rows [Location]'s field into 1 field.
I am hoping for a simple SQL solution to avoid me having to write some sort of webpage to do it.
I hope this makes sense.