Q&A for professional and enthusiast programmers
select ROW_NUMBER() OVER (order by CloseVoteCount DESC), f.*, 'site://review/close/' + CAST(r.Id as nvarchar) from (select COUNT(*) as CloseVoteCount, PostId, PostId as [Post Link] from PendingFlags where FlagTypeId=14 group by PostId) f inner join ReviewTasks r on r.ReviewTaskTypeId = 2 AND r.PostId = f.PostId and f.CloseVoteCount = 4 where r.DeletionDate is NULL order by CloseVoteCount DESC