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!

Pivot row to columns without aggregate function

Sibasish SahuMar 29 2019 — edited May 22 2019

Hello ,

     I am trying to fetch a data from database where i want to use pivot function. But i have seen in many examples it is requiring an aggregate functions of SQL.

Is there any way that we can do pivoting on string type data of a column & convert/ pivot the data as row with out SQL's aggregate functions.

Example :

SELECT * FROM PROPERTY

PROP_NAME     PROP_TYPE    PROP_VAL     ENVIRONMENT

-------------------     ------------------    ----------------     ----------------------

BANKING             A                         true                    DEV

IT                          B                         false                   TEST

TELECOM            C                         false                    TEST

MEDIA                  A                          false                    STAGE

APPLE                  D                          true                     PROD

MANGO                E                          true                    UAT

ORANGE              B                           false                   DEV

CARROT              C                             false                   TEST

BURGER              B                             true                      DEV

Now lets say i want data should show me like below

PROP_NAME      PROP_TYPE           DEV                TEST               STAGE               UAT               PROD

-------------------       ------------------         ---------------       ---------              ---------               -------              ---------

BANKING               A                              true                    NULL               NULL               NULL               NULL

IT                             B                             NULL                   false               NULL               NULL               NULL

TELECOM               C                            NULL                    false               NULL               NULL               NULL

MEDIA                    A                             NULL                     NULL              false               NULL               NULL

so on.

Can anyone please help me on this ? It will be really helpful for me.

Comments
Post Details
Added on Mar 29 2019
11 comments
55,375 views