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

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

Popular posts from this blog

Asp.net Publishing Broke Site - "App_WebReferences is not allowed because the application is precompiled"

Telerik - Custom Group Footers In RadGrid

Bootstrap Modal Popup is Grayed Out