Skip to Main Content

SQL & PL/SQL

display old and new values for n values of a column in a table

Uday_NFeb 15 2021

Hi All,
I have a table . I will update the table with the new value . I need to display old and new values as column. I tried PIVOT but since my entries are n in number i can't give definite values in FOR IN () in PIVOT .

EG:
CREATE TABLE TAB_A (ID NUMBER, EMP_ID NUMBER,NAME VARCHAR2(10),SALARY NUMBER);

INSERT INTO TAB_A (1,123,'Mike',1000);

INSERT INTO TAB_A (2,124,'Pete',2000);

INSERT INTO TAB_A (3,125,'Kevin',3000);

INSERT INTO TAB_A (4,123,'Mike',3000);

INSERT INTO TAB_A (5,124,'Pete',4000);

I need to display NAME,EMP_ID,OLD_SALARY,NEW_SALARY .

In real time , SALARY and EMP_ID are in definite not concluded to 3 values as mentioned above so I am not able to use FOR IN () . Please kind your advise

Regards,
Uday

This post has been answered by Solomon Yakobson on Feb 15 2021
Jump to Answer
Comments
Post Details
Added on Feb 15 2021
8 comments
444 views