Merge into one Row

  • Hi, All

    I have a q for U.

    Looks like really easy but when I try to this,this makes me crazy.

    There are 2 actually more than 4 but let's do just 2 tbls. One for Personel the other for PhoneNumber tbl(link with PersonID)

    Format is:

    PersonID PhoneType PhoneNum

    P1 Work 703-123-4567

    P2 Work 703-456-4215

    P2 Home 703-786-5148

    I want to query like this:

    PersonID WorkPhone HomePhoneNum

    P1 703-123-4567

    P2 703-456-4215 703-786-5148

    One row for all phone #s.

    Any Idea?

    Thx in advance.

    Jay

    Looks like esay but???

  • Check out the topic "insert three rows into one row of another table".

  • A Pivot table query would work for you. You should be able to modify my "Pivot table without case statement" example. You can find that example here:

    http://www.geocities.com/sqlserverexamples/#pivot1

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply