I have a database in access 2010.
A have a table that has some fields. Three of these are “input”, “output” and “date”.
A have also a total quantity query.
I want to sum all the “input” values that have the same “date” and I also want to sum all he “output” that have the same “date”.
I want my query to find the deduction result (“input” – “output” that have the same “date”).
My question is how to correlate different insertions that have the same “date” value.
Any help please?
EDITED:
input output date
3 0 2/5/2012
4 0 8/5/2012
0 2 2/5/2012
0 1 8/5/2012
I want my query to show
available stock date
(3-2=) 1 2/5/2012
(4-1=) 3 8/5/2012
EDITED v2:
My sql code is
SELECT SUM(warehouse.in_quant)-SUM(warehouse.out_quant) AS SUM,
drugs.active_substance, drugs.strength, drugs.strength_type, drugs.dosage_form,
warehouse.available_stock, drugs.minimum_quantity, IIf([warehouse]![available_stock]
[drugs]![minimum_quantity],"YES!","No") AS DiplayText, warehouse.curr_date
FROM drugs INNER JOIN warehouse ON drugs.ID = warehouse.drug_id;
I get this message:
You tried to execute a query that does not include the specified expression “active_substance” as part of an aggregate function.
When i remove the SUM(warehouse.in_quant)-SUM(warehouse.out_quant) AS SUM it works fine.
Go to the query design window, add the relevant tables, drag the fields that you want to match from one table to the next. Test. If it is not what you want, post the sql back here with sample data and an explanation of the problem.
You will probably need something more complicated, but this should be a start, hopefully.
Re comments