I have a history table table where i keep all the records whether they are inserted, updated or deleted. I want to select only the latest record as per below example. Example, Below are two transactions 23 and 24. I want to pick the latest update of 23 and want to skip 24 because it is deleted at the end. Please write a query for me.
Source:
Transaction Flag Date
23 I 1/1/2020
23 U 2/1/2020 I-Inserted
23 U 3/1/2020 U-Updated
23 U 4/1/2020 D-Deleted
24 I 1/1/2020
24 U 2/1/2020
24 D 3/1/2020
Result:
Transaction Flag Date
23 U 4/1/2020