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 using two values

chroniclexSep 3 2019 — edited Sep 4 2019
IDTitleCreated byPositionDate FromDate To
1abca1started01/01/1901/01/19
1abca2under review01/31/1902/12/19
2xyzb1started02/22/1902/22/19
2xyzb1under review02/23/19
2xyzb1in progress03/01/1903/10/2019

I am attempting to create a custom report in which the position values are columns. Example for Table A is above and the end result i am trying to achieve is below:

IDstarted_fromstarted_tounder review_fromunder review_toIn progress_fromIn progress_to
101/01/1901/01/1901/31/1902/12/19
202/22/1902/22/1902/23/1903/01/1903/10/2019

I was able to use pivot (below) and is able create columns for started, under review and in progress based on the values for from. However it is outputting all the columns in the table

SELECT *

    FROM Table A

PIVOT (

  MAX(Date From) FOR Position IN ('started','under review','in progress')

);

I tried to mention the values required (below), but i get an error invalid character

SELECT

ID,

Position,

Date From,

Date to

FROM Table A

PIVOT (

  MAX(Date From) FOR Position IN ('started','under review','in progress')

);

Please let me know if i am on right track.

Comments
Post Details
Added on Sep 3 2019
2 comments
343 views