Wayne Jordan
Registered User.
- Local time
- Today, 13:26
- Joined
- Feb 14, 2013
- Messages
- 14
I have had similar problems like this in the past but the old solutions don't seem to work here.
This is an inventory database.
I have two tables in this question, tlbIems and tblTransactions.
tblItems lists all items in my database, i.e. boxes, bubblewrap etc.
tblTransactions records when I receive or pick an item from stock.
I have to report submit a weekly report itemizing what we have used.
To make it simple, let's assume I have two items, A and B.
This week I received and picked some of item A but there are no transactions for item B. So when I ask for a report to show a sum what happened between 1/1/16 and 1/7/16 I want to see something like:
ItemID QtyRcvd QtyPicked
A 10 5
B 0 0
But all I get is
ItemID QtyRcvd QtyPicked
A 10 5
and item B is left off the report.
I select ItemId from tblItems because they are all listed there and I want all items to show up on the report. I use a LEFT JOIN. From past experiences (if I remember correctly which probably do not) I at least got a NULL response for item B and I was able to use NZ to make it a 0. But now I do not even get a null response, i just get nothing if there are no transactions for that item.
Here is the actual query
SELECT Items.ItemID, Sum(Transactions.Consumed) AS SumOfConsumed
FROM Items LEFT JOIN Transactions ON Items.ItemID = Transactions.ItemID
WHERE (((Transactions.TransDate) Between #1/1/2016# And #1/7/2016#))
GROUP BY Items.ItemID;
I am going crazy because I have had similar problems before and came to forum and found solutions. Even after reviewing those posts I cannot make this work.
Can someone please help before I shoot myself or this computer.
This is an inventory database.
I have two tables in this question, tlbIems and tblTransactions.
tblItems lists all items in my database, i.e. boxes, bubblewrap etc.
tblTransactions records when I receive or pick an item from stock.
I have to report submit a weekly report itemizing what we have used.
To make it simple, let's assume I have two items, A and B.
This week I received and picked some of item A but there are no transactions for item B. So when I ask for a report to show a sum what happened between 1/1/16 and 1/7/16 I want to see something like:
ItemID QtyRcvd QtyPicked
A 10 5
B 0 0
But all I get is
ItemID QtyRcvd QtyPicked
A 10 5
and item B is left off the report.
I select ItemId from tblItems because they are all listed there and I want all items to show up on the report. I use a LEFT JOIN. From past experiences (if I remember correctly which probably do not) I at least got a NULL response for item B and I was able to use NZ to make it a 0. But now I do not even get a null response, i just get nothing if there are no transactions for that item.
Here is the actual query
SELECT Items.ItemID, Sum(Transactions.Consumed) AS SumOfConsumed
FROM Items LEFT JOIN Transactions ON Items.ItemID = Transactions.ItemID
WHERE (((Transactions.TransDate) Between #1/1/2016# And #1/7/2016#))
GROUP BY Items.ItemID;
I am going crazy because I have had similar problems before and came to forum and found solutions. Even after reviewing those posts I cannot make this work.
Can someone please help before I shoot myself or this computer.