可以有多个 Config_RecID,但我只想显示附加到 SR_Service_RecID 的第一个,或者当为空时为 NULL。
SELECT s.SR_Service_RecID
, sc.Config_RecID
FROM SR_Service s
LEFT JOIN SR_Config sc
ON sc.SR_Service_RecID = s.SR_Service_RecID
WHERE (sc.Config_RecID =
(
SELECT TOP 1 sc.Config_RecID
FROM SR_Config sc
WHERE sc.SR_Service_RecID = s.SR_Service_RecID
)
OR sc.Config_RecID IS NULL)
有没有更好/更整洁的方法来做到这一点,还是我走在正确的轨道上?