T-SQL - Joining Out To Only One Row
This is an experpt of a larger select, but it shows the important section of how to only get back one row.
http://www.bennadel.com/blog/1093-getting-one-record-per-group-from-a-one-to-many-join.htm
http://www.bennadel.com/blog/1093-getting-one-record-per-group-from-a-one-to-many-join.htm
LEFT OUTER JOIN dbo.ClientAddressBridge AS CAB on c.ID= CAB.clientID AND CAB.[status]=1
AND
CAB.ID =
(Select Top 1
ClientAddressBridge2.ID
From
ClientAddressBridge as ClientAddressBridge2
where ClientAddressBridge2.clientID =c.id)
Comments
Post a Comment