Results 1 to 6 of 6
  1. #1
    Join Date
    May 2009
    Location
    Czech republic
    Posts
    5

    Unanswered: merge rows by SQL SELECT command

    Hi all,

    I have this table data:
    (example)

    INR ATTRIBUT
    ------------------
    120212 SA
    120212 D
    120212 N

    How merge rows with identical INR?
    Required result:

    INR MERGE_ATTRIBUT
    ------------------------
    120212 SA,D,N

    Thanks for any idea.

    Vladimir

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Search for "pivot" queries.

  3. #3
    Join Date
    Aug 2011
    Posts
    2

    Smile add rows in sql server

    Quote Originally Posted by resko View Post
    Hi all,

    I have this table data:
    (example)

    INR ATTRIBUT
    ------------------
    120212 SA
    120212 D
    120212 N

    How merge rows with identical INR?
    Required result:

    INR MERGE_ATTRIBUT
    ------------------------
    120212 SA,D,N

    Thanks for any idea.

    Vladimir
    select distinct inr,attribute=SUBSTRING((select ', '+ attribute from example e2 where e2.inr=e1.inr from xml path(''),elements),2,500) from examle e2

  4. #4
    Join Date
    Aug 2011
    Posts
    2

    Smile merger rows in sql

    Quote Originally Posted by resko View Post
    Hi all,

    I have this table data:
    (example)

    INR ATTRIBUT
    ------------------
    120212 SA
    120212 D
    120212 N

    How merge rows with identical INR?
    Required result:

    INR MERGE_ATTRIBUT
    ------------------------
    120212 SA,D,N

    Thanks for any idea.

    Vladimir
    select distinct inr,attribute=SUBSTRING((select ', '+ attribute from example e2 where e2.inr=e1.inr from xml path(''),elements),2,500) from examle e2

  5. #5
    Join Date
    Aug 2011
    Posts
    2
    That the more detailed.

  6. #6
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by nileshdubey View Post
    select distinct inr,attribute=SUBSTRING((select ', '+ attribute from example e2 where e2.inr=e1.inr from xml path(''),elements),2,500) from examle e2
    That's not a valid Oracle SQL statement

Posting Permissions

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