Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2017
    Posts
    1

    Unanswered: oracle to transform data

    i have a temp table as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name

    data_file.txt

    column_name file_name
    col1 file1
    col2 file2
    col3 file1
    col4 file1
    col5 file2

    now, i would like to output below result, which returns all the column name by file name as belows.

    file_name column_name
    file1 col1,col3,col4
    file2 col2,col5

  2. #2
    Join Date
    Mar 2007
    Posts
    629
    The output looks like the result of string aggregation, so I would use LISTAGG function. It is available from Oracle 11gR2.
    For lower Oracle versions, you may find methods for achieving this (description with examples) e.g. in this article: http://www.oracle-base.com/articles/...Techniques.php
    Just pick the one you like most and is available in your Oracle version. Only do not ever use WM_CONCAT, as it is unsupported.

Posting Permissions

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