I don’t know if my wording for this question may be off, but here’s the issue. I have to tables like the ones you see below. I Need to UNION the two tables, but divide Set1Count by Set2Count in the process. Please help.
(Note: I realize there may be another approach all together. Here are the details. Both tables have the exact same number of records – they are just built based on two different relationships. The result set must have the same number of records as the originals (not combine, but individually). Set1Count must be divided by Set2Count)
DECLARE @Set1 TABLE
(
Set1Count Int,
Name varchar(50),
[Month] Int,
[Year] Int
)
DECLARE @Set2 TABLE
(
Set2Count Int,
Name varchar(50),
[Month] Int,
[Year] Int
)
SELECT * FROM @Set1
UNION
SELECT * FROM @Set2
I’m guessing this should do:
Note that this will work correctly if there are the same records on both tables, since I’m using an
INNER JOIN. If that’s not the case, then you should probably use aFULL JOIN.