Hi i was wondering if anyone knows how i can calculate the difference between two tables in tsql. I dont mean finding which cells are different – i mean calulcating the numerical difference. eg – Table A has column1, column 2 and only one 1 row. A1 = 40, B1 = 30. Table B has column1, column 2 and only one 1 row. A1 = 25, B1 = 10. So how could i get (A1 = 15, B1 = 20) using TSQL?
Share
Given that you have no way to join the tables, you’ll need a Cartesian product of the two. Luckily since each table only has one record that’s not a problem.
You do it like this:
If you had more than one record in each table, this query would return a result for every pair of records in both tables. So if TableA had n records and TableB has m, the result will have n*m records.