Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2011
    Posts
    44

    Unanswered: Merge SQL columns

    Hi guys I have seen similar posts but just cant get what I need.

    I have a table which has 2 enteries for some people. ID and Name exist for each but the info fields will have one entery.

    For example

    Id,Name ,Info1,Info2,Info3,Info4,info5
    01,Mary Lambe,AAA, ,CCC, ,
    01,Mary Lambe, ,BBB , ,DDD,EEE

    How can I return

    01,Mary Lambe,AAA,BBB ,CCC,DDD ,EEE

    ie I need to merge the 2 into one.

    Regards,
    Conot

  2. #2
    Join Date
    Apr 2012
    Posts
    213
    Hi,

    Try:

    Code:
    select 
        Id,
        Name,
        max(Info1) as Info1,
        max(Info2) as Info2,
        max(Info3) as Info3,
        max(Info4) as Info4,
        max(info5) as Info5
    from MyTable
    group by 
        Id,
        Name
    Hope this helps.

  3. #3
    Join Date
    Sep 2011
    Posts
    44
    Thats it.. Thanks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •