Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert row into column, column as header

AceNoviceDec 16 2015 — edited Dec 17 2015

Hi All, Need to convert row into column dynamically. We have table, which contains incoming file name, load date and number of records loaded. We have data since 01-JAN-2015 and need to put it into tabular format, so that we can share with business to have analysis. I thought of using DECODE and MAX function to convert row into column, but since time period is long, it will require me to write 300+ expression using DECODE and MAX. I need your help to get data in below format. Below is sample data.

Source:

FILE_NAMELOAD DATERecord Loaded
TOPSAVEDONE03/12/2015500
TOPSAVEDONE04/12/2015600
TOPSAVEDONE05/12/2015450
TOPSAVEDONE06/12/2015300
TOPSAVEDONE07/12/2015100
LOWSAVEDONE03/12/20151000
LOWSAVEDONE04/12/20158000
LOWSAVEDONE05/12/20153000
LOWSAVEDONE06/12/20156700
LOWSAVEDONE07/12/20155555

Output:

FILE NAME03/12/201504/12/201505/12/201506/12/201507/12/2015
TOPSAVEDONE500600450300100
LOWSAVEDONE10008000300067005555
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 14 2016
Added on Dec 16 2015
9 comments
3,233 views