Link to home
Start Free TrialLog in
Avatar of SharonBernal
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.
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial