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!

Write a query for following output

Discussion in 'SQL PL/SQL' started by ashish kumar, Feb 13, 2014.

  1. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,616
    Likes Received:
    364
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    You can also use the undocumented function wm_concat in 10g:


    Code (SQL):

    SQL> WITH xyz AS
      2         (
      3          SELECT 'delhi' branch, 1000 population  FROM dual UNION ALL
      4          SELECT 'noida' , 1500 FROM dual UNION ALL
      5          SELECT 'gurgaon' , 2000 FROM dual UNION ALL
      6          SELECT 'ghaziabad' ,3000 FROM dual
      7         )
      8    SELECT
      9          wm_concat(branch)
     10    FROM xyz
     11    UNION ALL
     12    SELECT
     13          wm_concat(population)
     14    FROM  xyz ;


    WM_CONCAT(BRANCH)
    --------------------------------------------------------------------------------
    delhi,noida,gurgaon,ghaziabad
    1000,1500,2000,3000


    SQL>