I have an issue where I need to update a table by evaluating the update date against the last updated date (SC_LastDate).
I will need to add a new record and remove the old record if the update has occured within the same month as the initial timestamp (SC_LastDate). If the update has occured in a different month, then append a new record to the table and maintain the old record.
The table in question is below:
For example, SC_CompanyCode 151 may be updated on the 03/05/2010 and hence a new record requires to be appended to the table. If that record was then updated on the 05/05/2010, I would need to overwrite the existing record (03/05/2010) with the new record (05/05/2010).
i.e. IF monthname(updatedate) <> monthname(SC_LastDate) THEN append new record
ELSE IF monthname(updatedate) = monthname(SC_LastDate) THEN overwrite existing record