Is it possible via select query: I have the followng sample data, based on acct_unit, i want to put either Initial Row' or Updated Row' in Status_Flag field.If Based on acct_Unit, if the date is latest then want to put 'Updated Row', if old then want to put 'Initial Row'If there is only one row based on Acct_unit, then want to put 'Initial Row'Declare @Sample table (acct_unit varchar(10), STATUS_DATE datetime, STATUS_FLAG varchar(20), SUR_KEY Int)insert @Sampleselect '168','20-OCT-2012', '', 19 union allselect '168','16-Oct-2012', '', 12 union allselect '173','24-Oct-2012', '', 26 union allselect '173','20-Oct-2012', '', 22 union allselect '182','17-Oct-2012', '', 14
Result should be Acct_unit=168 - status_Flag = 'Updated Row' - surkey=19Acct_unit=168 - status_Flag = 'Initial Row' - surkey=12Acct_unit=173 - status_Flag = 'Updated Row' - surkey=26Acct_unit=173 - status_Flag = 'Initial Row' - surkey=22Acct_unit=182 - status_Flag = 'Initial Row' - surkey=14Thanks a lot for the helpful information.