sums on a quary

M

matjcb

Hello,
I’m building a query that I would like to sum quantities of a part number
used on multiple Purchase Orders

Example

PO Item # qty sum
16 100 2 5
27 100 1 5
39 100 2 5
19 200 2 7
26 200 5 7

Thanks
 
J

Jason Lepack

Let's say for sanity sake that you have this table:

pos:
po - number
item - number
qty - number

create query to get sums (called sums)
select
item,
sum(qty) as sum_qty
from
po
group by
item

create a new query for your final result:
select
po,
item,
qty,
sum_qty
from
po
inner join sums
on po.item = sums.item

Cheers,
Jason Lepack
 

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