Updating table A with sum values from tables B and C

  • Thread starter Thread starter drolfe
  • Start date Start date
D

drolfe

Preface:

Table A:
Primary Key - Foreign Key - OutValueA - OutValueB - OutValueC
--------------------------------------------------------------------------------------------------
1 1 3 0
20
2 2 2 1
30


Table B:
Primary Key - Foreign Key - InValueA - InValueB
-------------------------------------------------------------------------
1 1 -1 0
2 1 -1 0
3 1 -1 0
4 2 0 -1
5 2 -1 0
6 2 -1 0

Table C:
Primary Key - Foreign Key - InValueC
--------------------------------------------------------
1 1 20
2 1 20
3 2 30
4 2 30

Requirement:
I need to count the check boxes from InValueA and InValueB into
OutValueA and OutValueB
To average the TableC (per Foreign Key) into OutValueC

I made some crosstab querys and was able to get the desired result, but
was unable to combine the three querys into a single table.

Any ideas??
 
Where to start?

The first, usually if you don't get an answer quickly, it's because
people don't understand your problem and you might be able to restate
it in easier to understand terms.

Second, why do you have fields in your table called "Foreign Key"? The
definition of a Foreign Key is that the field in another table that
this field relates to is a Primary Key.
Ex.
tbl_car:
car_id - Primary Key in this table
car_info

tbl_renters:
renter_id - Primary Key in this table
renter_info

tbl_rentals:
rental_invoice_id - Primary Key
car_id - Foreign Key - it's unique in a another table
renter_id - Foreign Key - it's unique in another table as well

Lastly, why would you want to waste disk space on storing a calculated
value when at any time you could run a query to retreive that value?

Cheers,
Jason Lepack
 

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

Back
Top