A1VBCode Forums

Help with sql query


http://www.a1vbcode.com/vbforums/Topic32135.aspx

By ronyjosef - 3/7/2014

hello friends

I'm running this query on an MDB file from vb.Net,The inner SELECT works fine but when wrapped in the outer SELECT, I get the error "An action query cannot be used as a row source."





select * into NewTable

from

(

SELECT 'Table1' AS [Table], SUM(a) - SUM(b) AS Result FROM table1 union all

SELECT 'Table2' AS [Table], SUM(a) - SUM(b) AS Result FROM table2

)








SELECT "Table1" AS Table, SUM(a) - SUM(b) AS Result FROM table1

UNION

SELECT "Table2", SUM(a) - SUM(b) FROM table2

UNION

SELECT "Table3", SUM(a) - SUM(b) FROM table3



It gives me this output

table | result

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





I would like to know how do I update the below table "new table" with results column from output table?



name | table | result

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