SharonBernal
asked on
SQL Server Complex join
I have a query as follows:
select * from TBL1 inner join TBL2 where tb1.groupkey=tbl2.groupkey
I want to keep these records, however here's the problem, if groupkey is null or ZZ I need to execute the same select with a different table and where condition
select * from TBL1 inner join TBL3 where tb1.groupkey=tbl3.groupkey
Finally if this brings back duplicates I need to set groupkey to null.
I need help designing this query.
select * from TBL1 inner join TBL2 where tb1.groupkey=tbl2.groupkey
I want to keep these records, however here's the problem, if groupkey is null or ZZ I need to execute the same select with a different table and where condition
select * from TBL1 inner join TBL3 where tb1.groupkey=tbl3.groupkey
Finally if this brings back duplicates I need to set groupkey to null.
I need help designing this query.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.