I have a table with 4 columns. ID is a unique number , you can have the same id_number with different update_dates. In the current table all FLAGS are set to 'Y', however what i want to do is set the FLAG to 'Y' only for the max update_date for each ID/ else N. any unique ID that has a count > 1 i should look to see the max update_date and flag that with a 'Y' the else 'N' for (historical purposes).
I need an update statement that will update the FLAG in my existing tables based off the update_date.
current setup
ID,ID_NUMBER,UPDATE_DATE,FLAG
1,ws5412,02-25-18,Y
1,ws5412,06-21-18,Y
1,ws5412,01-2-14,Y
1,ws5412,05-8,16,Y
EXPECTED OUTPUT
06-21-18 is flagged 'Y' since its the most recent update_date
ID,ID_NUMBER,UPDATE_DATE,FLAG
1,ws5412,02-25-18,N
1,ws5412,06-21-18,Y
1,ws5412,01-2-14,N
1,ws5412,05-8,16,N