SQL2008R2 Express...
Provided I had a row of data that appeared as such...
Value   ID  User
10      5   1
11      7   1
22      5   2
 9      9   2
And I wanted to run a query as such to determine what the sum of value was by user...
SELECT [user], SUM([value])[value] FROM [MyTable] GROUP BY [user]
which would yield
User   Value
1      32
2      31
All is well, but now say I wanted a representation of what values from the [ID] column contributed to that total?
The scenario is that users perform various tasks that have values ultimately to be summed, averaged, etc.... And I wish to know what specific task lead to the total I am seeing. Essentially a DISTINCT list of all the rows compressed into the aggregation, delimited in some way of course so I can distinguish / parse them on another level. end result would look something like this...
User   Value   IDs
1      32      5,7
2      31      5,9
Is this doable without going RBAR with temporary tables?
 
    