DECLARE @customer TABLE ( ID INT, [Name] VARCHAR(100), [Type] VARCHAR(10))
DECLARE @documents TABLE ( ID INT IDENTITY, [Type] VARCHAR(100), CustomerID INT )
INSERT INTO @customer VALUES (1, 'Олег','ФОП'),
(2, 'Женя','Юр.лицо'),
(3, 'Таня','Физ.лицо'),
(4, 'Коля','Физ.лицо')
INSERT INTO @documents VALUES ('паспорт', 1),
('инн', 1),
('загран',1),
('паспорт',2),
('инн',2),
('загран',2),
('паспорт',3),
('инн',3),
('загран',3),
('паспорт',4),
('инн',4),
('загран',4)
SELECT * FROM @customer AS Customer
LEFT JOIN @documents AS Document ON CustomerID = Customer.ID
WHERE Customer.[Type] = 'Физ.лицо' AND Document.[Type] IN ('паспорт','инн','загран')
UNION
SELECT * FROM @customer AS Customer
LEFT JOIN @documents AS Document ON CustomerID = Customer.ID
WHERE Customer.[Type] <> 'Физ.лицо' AND Document.[Type] IN ('паспорт', 'инн' )