I know this has been asked before but I can’t seem to find a solution that fits.
I have this data:
Label StartDate ActivityKey
------------------------------------------------------------------
LABELS 2009-02-12 23D645CA-7F05-47FF-9AC4-1414DCBF44DD
LABELS 2010-11-01 C266A254-2A3D-4A37-8281-AE9EA08ED086
MASTER BOXES 2009-02-12 81DBEA52-B7BC-4861-96B4-7A77A2D7F07B
MASTER BOXES 2010-11-01 9DAD9F77-46FD-4694-9168-E4E5FE306B7D
I only want the most recent for each Label. This is desired:
Label StartDate ActivityKey
------------------------------------------------------------------
LABELS 2010-11-01 C266A254-2A3D-4A37-8281-AE9EA08ED086
MASTER BOXES 2010-11-01 9DAD9F77-46FD-4694-9168-E4E5FE306B7D
Thanks for any tips
(BTW, this is SQL Server 2008)
The same query can also be done with a CTE: