How to set a flag in SQL, when there is a change in value I have column which tells fee rates.
When there is change in value in that column, I need to set a flag for that corresponding row.
How can i check whether there is change in value from previous row and current row and flag it accordingly. There are l0's of thousands of records.

Please find below, when rate changes, then that row I have to flag.
It depends on what you want to do based on that flag.

If you only care that the row has &quot;changed&quot; at some point, then a flag might be enough.
If you care when the change happened, then a [nullable] timestamp might be more useful.
If you care if the change happens more than once, then you need a whole new table to record all of those changes, possibly even with &quot;before&quot; [and &quot;after&quot;] values.

In any case, the answer is the same - a Trigger.