Calculate

  • Thread starter Thread starter gatarossi
  • Start date Start date
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.
 
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

Medium Price 4
calculation 5
Excel Complex Summing 3
Write calculated control to table 1
Calculate Difference 1
Comparing data between two tables 1
Multiple field match? 3
Rankings 6

Back
Top