I've look around and I haven't find anything in the Web pointing me to the right direction, so I'll try the knowledgeable stackoverflow people :)
I have 4 tables in Microsoft Access 2007 (Warehouse
, Cars
, TVs
, Toys
).
__(many) Cars
/
Warehouse 1---(many) TVs
\__(many) Toys
The Warehouse table has a 1-to-many realtionship to Cars, TVs, Toys on the WarehouseNumber field I've been trying to make a query that would give me the sum Dollar Value
(that is a field in Cars, TVs, and Toys tables). I am doing it with Joins, but maybe is the wrong way to go. I only know the basics about joins, never work with them before though.
First I am trying to get distictive records based on the Warehouse.WarehouseNumber
field value like this:
SELECT Warehouse.[WarehouseNumber], Cars.[DollarValue], TVs.[DollarValue]
FROM (Warehouse INNER JOIN Cars
ON Warehouse.[WarehouseNumber] = Cars.[WareHouseNumber])
INNER JOIN TVs ON TVs.[WarehouseNumber] = TVs.[WarehouseNumber];
But I get repetitive records like this (this is just dummy data):
WarehouseNumber | Cars.DollarValue | TVs.DollarValue
1111-1111 | $8,000.00 | $500.00
1111-1111 | $8,000.00 | $800.00
1111-1111 | | $500.00
1111-1111 | | $800.00
1111-3333 | $1,000,000.00 |
1111-3333 | $21,000.00 |
Is there a better way to do this? Thanks for the help in advance
UPDATE: I gave the answer to Remou for the simplicity in the query and being the first one, but all the examples so far didn't gave me any repetitive records. Thanks for the fast help guys, you are making access more bearable for me.