"Sum" according to products

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with two products (currently) "petrol" & "diesel"

------------------------------------------------------------------------------------
ID Product_iD Product Original_amt Draw Outstanding
1 101 Petrol 1200 100 0
2 102 Diesel 3000 50 0
3 101 Petrol 1200 150 0
4 101 Petrol 1200 200 0

------------------------------------------------------------------------------------

I bought $1200 of Petrol and $3000 for the Deisel.

As time goes, i draw them down for private use.

------------------------------------------------------------------------------------

My question:

I'd like to see the "sum of total draw-down" of each product.

------------------------------------------------------------------------------------


Therefore, my desired result should look like this:



product_id product Total_Draw_Down
101 Petrol 450
102 Diesel 50
 
Hi Allen

product_id product Total_Draw_Down

Try the following SQL...

select product_id, product, sum(draw_down) as total_draw_down
from TableName
group by product_id, product


hth

Andy Hull
 
Back
Top