In the stord procedure below. I am retreiving all the records for that 1 deal. What I want is to retreive the most recent record hence the one with the most recent in the AddedDate field.
How can I accomplish this?
SET NOCOUNT ON
SELECT deals_Comments.CommentID, deals_Comments.AddedDate, deals_Comments.UserID, deals_Comments.AddedByEmail, deals_Comments.AddedByIP, deals_Comments.DealID, deals_Comments.Body, deals_Comments.SBody,
ROW_NUMBER() OVER (ORDER BY deals_Comments.AddedDate DESC) AS RowNum
WHERE deals_Comments.DealID = @DealID
View Complete Post