I am trying to build a Function that returns the PlacerUserKey that is associated with the most recent record in a table. How do I go about returning the User record that has the most recent Created date? The function below does not work. Thank you.
CREATE FUNCTION dbo.GetCurrentPlacer
DECLARE @CurrentPlacer VARCHAR
SELECT @CurrentPlacer = (MAX(Created) AS CurrCreated, PlacerUserKey
FROM Placer AS pl
WHERE (OrderKey = @OrderKey)
GROUP BY Created, PlacerUserKey
ORDER BY Created DESC)