0

I have multiple data tables and I want to add together some values.

Table1 
Item      units
xx        1
yy        2   
zz        3

Table2
Item      Units
xx        1
yy        2
zz        3

Table3
Item      Units
xx        1
yy        2
zz        3

What I need returned is basicly Totals

so

xx = 3
yy = 4
zz = 6

This has to be done with multiple tables. I am attempting to do this in Access and I have no idea how to start.

Edit:

How would I also get it to display an associated value?

For ex:

 Table1 
 Item       units       Associated Value
 xx         1           randomval1
 yy         2           randomval2

 Table2 
 Item       units       Associated Value
 xx         1           randomval1
 yy         2           randomval2

so then the resulting output should be

 xx randomval1 = 2

Is this do able?

1
  • Anyone can help with the modified question? Commented Nov 23, 2013 at 22:39

1 Answer 1

2

you have to create a SQL Request which will join your data and make a sum afterwards

SELECT Item, SUM(Units)
FROM (
    SELECT Item, Units 
    FROM Table1
    UNION ALL
    SELECT Item, Units 
    FROM Table2
    UNION ALL
    SELECT Item, Units 
    FROM Table3
) 
GROUP BY Item
Sign up to request clarification or add additional context in comments.

4 Comments

+1. I posted a similar answer, but yours is cleaner.
Thanks for that. That worked great. One more question how do I only display the value of another column... Like Title per say.
Title ? is it part of your tables? explain more what your are expecting
Yes there is a Title field as part of my tables. for ex Item Title Units And I just want to have title Displayed along with the Item

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.