Hi All,
I have a database with a couple of tables in it. One table is an input table and the second table is a detail table. When a record is entered it has a tool box which is unique. Each number is in sequence and has the same main number with a sequential trail number(i.e. 46001-1, 46001-2, 46001-3, 46001-4). So, in that series there are 4 inputs into the database. I want to count them together, and see how many instances there are of that particular tool box. So I wrote the following query:
Code:
SELECT Left([CGBoxStatusIn]![CGBox],5) AS CGBox_Number, Count(Left([CGBoxStatusIn]![CGBox],5)) AS HowmanyFROM CGBoxStatusIn INNER JOIN ToolDetail ON CGBoxStatusIn.CGBox = ToolDetail.[CGBox]
GROUP BY Left([CGBoxStatusIn]![CGBox],5);
And this gives me the result I'm looking for, now I am trying to use the results from this query and I'll give a example of the data :
CGBox |
ScanIn |
id |
missing |
ScanOut |
missingOut |
46001-3 |
2/18/2018 7:14:08 AM |
416 |
0 |
|
0 |
46002-1 |
2/13/2018 7:14:16 AM |
417 |
5 |
|
0 |
46001-1 |
2/10/2018 8:48:49 PM |
418 |
6 |
|
0 |
46001-2 |
2/7/2018 8:49:01 AM |
419 |
4 |
|
0 |
46001-4 |
1/21/2018 8:49:17 AM |
420 |
0 |
|
0 |
46002-2 |
1/18/2018 8:49:25 AM |
421 |
3 |
|
0 |
46002-3 |
2/3/2018 8:49:35 AM |
422 |
0 |
|
0 |
|
So, my other table has tool detail in it, which shows how many tools are in a box, so I need to inner JOIN on the other table and get the get the amount of tools in a box, so I can multiply that by how many tools are in the total minus the missing which is in another field in my original table. So I would link the tables on the CG Box number count the number of instances of 46001 (in this case there are 4) and inner join and find out in the tool detail table that there is 8 tools per box * 4 boxes in this example. For the other number in this table 46002, there are 3 boxes in the series and 10 tools per box.
I hope I'm not over explaining here but, in a nutshell I need the above query to inner join to another table so I can grab the data in the field which says how many are in a box and multiply it by how many boxes are in that series...so for the 46001 example the anwser would be 4 boxes times 8 tools in a box
Thanks,
Lenny