0

I'm having a mindblank here but my question is quick.

I have a table like the following:

Cust    Part    Qty    Rtn Qty 
Joe      A1      2        0 
Joe      A2      3        1 
Joe      A1      2        2
Bob      A1      3        4
Bob      A2      4        0

I want the results to be like:

Joe      A1      4        2
Joe      A2      3        1
Bob      A1      3        0
Bob      A2      4        0

I'm trying to figure out how to create a sum for each customer individually according to the part?

4

1 回答 1

2

That looks like a straightforward group by on Cust, Part:

select  Cust
,       Part
,       sum(Qty)
,       sum([Rtn Qty])
from    YourTable
group by
        Cust
,       Part
于 2012-07-09T20:43:29.117 回答