Here is the data
Flag Zone Info Date
R North AAA 2010-2-14
R North AAA 2010-2-24
T North AAA 2010-2-4
R South AAA 2010-2-23
T South AAA 2010-2-14
R EAST AAA 2010-2-22
T EAST AAA 2010-2-11
T EAST AAA 2010-2-1
T EAST AAA 2010-2-14
R WEST AAA 2010-2-29
Here is a table in the SQL SERVER, now I want to get a record from each group based on Zone column. The Flag field of this record should be R, and the Date should be the closest and after today’s date.
Best Regards,
Using ROW_NUMBER you can try
If you cannot use ROW_NUMBER you could try
But this will not exclude duplicates…