I have table 1 include, projectID, PO#, POcost
table2 include, project ID, invoice#, invoice cost. PO#
in table2, the PO# could happen multiple times, coz we can pay multiple times to pay the full amount of the original PO(in table1).
Now I want to get a form list
project ID, sumofPOcost(from table 1), sumof invoicecost (from table2), variance between POcost and invoice cost. I can get table 1's PO#key words.
My question is for the sumofPOcost I can use group by, so it won't duplicate based on how many matching invoice record there. But how I can get the variance based on each project without counting too many times' POcost?
Thank you very much!