1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Merging records into single line

Discussion in 'SQL PL/SQL' started by kiran.marla, Dec 26, 2011.

  1. kiran.marla

    kiran.marla Forum Genius

    Messages:
    403
    Likes Received:
    52
    Trophy Points:
    505
    Location:
    Khammam
    Hi friends,

    Attached is the excel file.

    Problem description with sample data.

    ---------------ATTRIBUTE_CATEGORY
    8E+11 CR\00008 Engine Details - - AEGPA6911C - - - - - - INTERNAL_SITE Plant&Mach Noida
    8E+11 CR\00008 Insurance Details - - - - - - - - 20-FEB-0025 INTERNAL_SITE Plant&Mach Noida

    Here due to attribute category like Engine Details, Insurance details we get two different records , Is it possible (in SQL) to merge two records into single , removing attribute_category and want to display data like


    8E+11 CR\00008 - - AEGPA6911C - - - - - 20-FEB-0025 INTERNAL_SITE Plant&Mach Noida


    I know we can do all magics in PL/SQL. But still i want to confirm with my friends whether can possible in through SQL.
     

    Attached Files:

  2. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
  3. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,345
    Likes Received:
    347
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    It would appear that the LEAD() or LAG() analytic functions combined with CASE() would allow you to condense these two records into one. Many examples are available on the web for such projects so I shall not clutter the landscape with any here.