Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Combine SQL Results

$
0
0

I have a query after joins some people have multiple phone numbers rt_telephone, which causes multiple results. How can I modify this query to create a phone_1 and phone_2 if there happens to be more than 1 phone number?

Select ResidentKey,

(rc_LastName) as 'Sort Name'

,(rc_FirstName + ' ' + rc_LastName) as Name

,rc_Address,rc_Address2,rc_City,rc_State,rc_Zipcode,u_StreetNumber,u_StreetName,u_UnitNumber,u_City,u_State,u_Zipcode,rt_Telephone,rc_email,co_name

From dbo.ResidentContact JOIN dbo.unit

ON (ResidentContact.ResidentKey = unit.UnitKey)

JOIN dbo.Community ON (unit.CommunityKey = Community.CommunityKey)

JOIN dbo.ResidentTelephone ON (ResidentContact.ResidentContactKey = ResidentTelephone.ResidentContactKey)

Where ResidentKey='12245'


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>