I have a historized table in SQL Server where the id (part of a composite key) repeats when a record is altered. For now, I would like to check which rows with the same id have a difference ONLY in col_a. Suppose the following data sample:
row_id | id | col_a | col_b
------------------------------
1 | 1 |value_a | value_b
2 | 1 |value_a | value_c
3 | 1 |value_d | value_c
4 | 1 |value_e | value_c
5 | 1 |value_f | value_g
I would like my output to be the following:
row_id | id | col_a | col_b
-------------------------------
3 | 1 | value_d | value_c
4 | 1 | value_e | value_c
My data has a lot more columns, but the idea is that I really want to return a table that contains only rows that have been duplicated to track a change in col_a and nothing else. Preferably without having to create/write to a table. I added the row_id for illustration purposes, I would have to create it out of the composite key if required to solve the problem.