One approach is to use CTE (Common Table Expression).
With this CTE, you can break down your data according to some criteria - i.e. your ContentID and Actiontype - and have a SQL Server number for all of your rows, starting at 1 for each of these "sections" ordered by ActionDate .
So try something like this:
;WITH Actions AS ( SELECT ActionID, ActionType, ActionDate, UserID, ContentID, RowNum = ROW_NUMBER() OVER(PARTITION BY ContentID, ActionType ORDER BY ActionDate DESC) FROM dbo.YourTable WHERE ...... ) SELECT ActionID, ActionType, ActionDate, UserID, ContentID, FROM Actions WHERE RowNum = 1 ORDER BY ActionDate DESC
Does this mean what you are looking for?
source share