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.
| customer | first name | last name | address | city | state | begin date | end date | |
| ABCD | X | TT | 123 STREET | SOMEWHERE | FG | 3/10/2015 | | (Last Update) |
| ABCD | X | ZZ | 146 MAIN | SOMEWHERE | FG | 3/1/2015 | 3/10/2015 | (First Insert) |
| DEFT | OP | WE | 78 ONE ROAD | THIS CITY | PL | 3/10/2015 | | (Last Update) |
| DEFT | OP | WE | 78 ONE ROAD | | HJ | 3/1/2015 | 3/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.
| customer | pior first name | current first name | prior last name | current last name | prior address | current address | prior city | current city | prior state | current state |
| ABCD | | | ZZ | TT | 146 MAIN | 123 STREET | | | | |
| DEFT | | | | | | | | THIS CITY | HJ | PL |
Tahnk you everyone for your assistance.