你好,
可以使用case when 来做这个条件。
Select
A.Name,
A.Age,
A.Sex,
CASE
WHEN a.Name = b.Name and a.Age = b.Age and a.Sex = b.Sex THEN a.Height
ELSE NULL END
as height
From A
join B on A.AId = B.BId
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.