How to select most recent records if the records are having almost same kind of data…
example:
col1 col2 col3 col4
--------------------------------------------------
123 abc 1.1 12345
123 abc 1.1 123445
1234 dsv 2.0 123
1234 dsv 2.0 1233
12345 dsvw 1.2 1234
The maximum of col4 when it compares with rest of the columns.
See the row1 and row2 data looks similar but we need the latest data based on col4.
Same thing with row3 and row4, data looks similar but we need the latest data based on col4.
And the required output is:
col1 col2 col3 col4
----------------------------
123 abc 1.1 123445
1234 dsv 2.0 1233
12345 dsvw 1.2 1234
Use:
..or:
The CTE doesn’t provide any optimization over the derived table approach.