"Sum" according to products

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top