troubleshooting Question

Generic Pivot Query

Avatar of gs79
gs79 asked on
Oracle Database
5 Comments1 Solution396 ViewsLast Modified:
This is in Oracle 10g

I have  a table say 'ABC' as follows..

ID      GCF      VAL1      VAL2
123       gcf1       581       48
123       gcf2       400       45
222       gcf1       100       55
222       gcf2       100       22
300       gcf1       20       40

I want a query to have a result something like below:

    ID      gcf1_val1   gcf1_val2   gcf2_val1   gcf2_val2
    123     581             48                400              45
    222     100             55                100              22
    300      20              40
.
The query needs to be expandible..Right now the table ABC has only 2 values for gcf which is gcf1 and gcf2..if a new value gcf lets say GCF3 comes in to ABC, the query should include gcf_3_val1, gcf3_val2 etc..

similarly if a new column say VAL3 is added to the table, then the query should give output all gcf values for the new column..ie
gcf1_val3, gcf2_val3, gcf3_val3 and so on..

I cannot use pivot operator as it is not available in 10g..

please let me know if there is a way..

Thanks
e
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros