I have a union query with 2 source tables
T1 with 150 records
T2 with 6 records
each table has 4 fields in each
MonthEndDate
AccountNumber
Value
SourceTableName
When I do the union query all 156 records result, but that is not what I want. If the same AccountNumber / MonthEndDate combination exists in both tables I only want the T2 record.
The result should be every record in T2, and only the records in T1 where the combination of MonthEndDate and AccountNumber are unique (do not have a match in T2).
This would be 150 records - 6 from T2, and 144 from T1.
Standard join conditions using all T2 will only give me the 6 T2 records and nothing from T1, so I need to use the Union (I think).
I tried some WHERE EXISTS and WHERE NOT EXISTS conditions but cannot quite get it.
If you could send back the lines of code I'd sure appreciate it. Have been playing with this for some time with no luck. Im sure it is something simple.
Thanks a bunch.
T1 with 150 records
T2 with 6 records
each table has 4 fields in each
MonthEndDate
AccountNumber
Value
SourceTableName
When I do the union query all 156 records result, but that is not what I want. If the same AccountNumber / MonthEndDate combination exists in both tables I only want the T2 record.
The result should be every record in T2, and only the records in T1 where the combination of MonthEndDate and AccountNumber are unique (do not have a match in T2).
This would be 150 records - 6 from T2, and 144 from T1.
Standard join conditions using all T2 will only give me the 6 T2 records and nothing from T1, so I need to use the Union (I think).
I tried some WHERE EXISTS and WHERE NOT EXISTS conditions but cannot quite get it.
If you could send back the lines of code I'd sure appreciate it. Have been playing with this for some time with no luck. Im sure it is something simple.
Thanks a bunch.