Click here to Skip to main content
15,904,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can someone help me with this
I have an Access Database on which I have tables with similar structure and columns name column ‘a’ and column ‘b’. I can use the below query to get this output.
Table | result

-------|--------


SELECT "Table1" AS Table, SUM(a) - SUM(b) AS Result FROM table1                                                           UNION                                                                                                                                                         SELECT "Table2" AS Table, SUM(a) - SUM(b) AS Result FROM table2                                             UNION                                                                                                                                                         SELECT "Table3" AS Table, SUM(a) - SUM(b) AS Result FROM table3 


I would like to know is there any way to write a query without hard coding the table names in query? I have posted c# section of the forum under same title.
www.codeproject.com/.../How-Sum-values-in-dynamic-table-column[^]
Posted
Comments
W Balboos, GHB 8-Aug-14 12:06pm    
Would having the table names as pars in a stored procedure do it for you? Construct the query in the SP and then EXEC it.

1 solution

can you show me an example how to do it in ms access please?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900