Q&A for professional and enthusiast programmers
WITH Scores AS ( SELECT PostTypes.Name AS Type, PostsWithDeleted.Id, CreationDate, Score FROM PostsWithDeleted INNER JOIN PostTypes ON PostTypeId=PostTypes.Id WHERE OwnerUserId=54957 UNION ALL SELECT N'Comment', PostId, CreationDate, Score FROM Comments WHERE UserId=54957 ) SELECT Type, P2.Title, Scores.CreationDate, Scores.Score FROM Scores INNER JOIN PostsWithDeleted AS P1 ON Scores.Id=P1.Id INNER JOIN PostsWithDeleted AS P2 ON COALESCE(P1.ParentId, P1.Id)=P2.Id ORDER BY Scores.CreationDate