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!

Compare rows/columns on same table and display differences in one row

580999f6-e681-49e9-881b-8879d9465c9aMar 11 2015 — edited Mar 11 2015

I have a history table that tracks changes on any of the columns as shown below. Initially a record is inserted into the table with the current data (first insert). Every time a change occurrs in any of the columns, the first insert will record an end date and a new row will be inserted with the new data but no end date (last update). The new row will display the new values if changed and the same values as the previous row if there were no changes made.

customerfirst namelast nameaddresscitystatebegin dateend date
ABCDXTT123 STREETSOMEWHEREFG3/10/2015 (Last Update)
ABCDXZZ146 MAINSOMEWHEREFG3/1/20153/10/2015(First Insert)
DEFTOPWE78 ONE ROADTHIS CITYPL3/10/2015 (Last Update)
DEFTOPWE78 ONE ROAD HJ3/1/20153/10/2015(First Insert)

I need to retrieve only one row per customer and display the last changed to the record showing the prior value and current values only If there was a change on any of the colums. If no change column value should be blank.

customerpior first namecurrent first nameprior last namecurrent last nameprior addresscurrent addressprior citycurrent cityprior statecurrent state
ABCD ZZTT146 MAIN123 STREET
DEFT THIS CITYHJ

PL

Tahnk you everyone for your assistance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2015
Added on Mar 11 2015
2 comments
2,500 views