Calculate

G

gatarossi

Dear all,

In my table, I have this fields:

item_code type quantity
xxxx1 IST 100
xxxx1 INV -300
xxxx1 FST 200

Then I need to do a consult that brings this:

= (FST) + (INV*-1) - (IST)
= (200) + (-300*-1) - (100)
= 400

How can I do it?

Thanks in advance!

Andre.
 
D

Douglas J. Steele

Is it fair to say that you want to add FST, add INV times -1 and add IST
time -1? (that's a slight restatement of your post, but at least for that
one case, it amounts to the same thing) If so, add another table that
indicates which fields need to be multiplied by -1:

Type Multiplier
IST -1
INV -1
FST 1

You can then join that table to your existing table, and create a query
along the lines of:

SELECT table1.item_code, Sum(table1.quantity * table2.multiplier) As Total
FROM table1 INNER JOIN table2
ON table1.type = table2.type
GROUP BY table1.item_code
 

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

Similar Threads

Safety Stock 0
VBA works in orignal but fails in copy of database 1
Medium Price 2
¿How to divide a total into 0
drag formula down from columns that go acros 3
Calculate Difference 1
calculation 5
Rankings 6

Top