Oracle SQL Developer: How to transpose rows to columns using PIVOT function Oracle SQL Developer: How to transpose rows to columns using PIVOT function oracle oracle

Oracle SQL Developer: How to transpose rows to columns using PIVOT function


You have a stray semi-colon in your statement, after:

    WHERE partyId = 100; 

Remove that to make it:

SELECT * FROM   (     SELECT partyId, contacttext, contacttypecd     FROM CONTACT     WHERE partyId = 100  )   PIVOT (     MAX(contacttext)   FOR contacttypecd in (1 Phone, 2 Fax, 3 Mobile, 4 Email));   PARTYID PHONE        FAX          MOBILE       EMAIL      ---------- ------------ ------------ ------------ ------------       100 0354441010   0355551010   0428105789   abc@home.com

It's being seen as multiple statements; the first is incomplete because it's missing a closing parenthesis (so gets ORA-00907), the second starts with that parenthesis and gets the error you reported, and then each subsequent line gets the same error. You only seem to be looking at the last reported error - it's usually much more helpful to start with the first error, clear that, and then move onto the next if it still exists.