Q&A for professional and enthusiast programmers
select top 30 Type, QId as [Post Link] from ( select top 120 (case when min(h.Comment) = '2' then 'OT' else 'TL' end) as Type, q.Id as QId from PostHistory h join Posts q on q.Id=h.PostId -- closed where h.PostHistoryTypeId=10 and q.ClosedDate is not null -- not locked and isnull((select top 1 PostHistoryTypeId from PostHistory where PostId=q.Id and PostHistoryTypeId in (14,15,35) order by CreationDate desc),0) not in (14,35) -- off-topic or too-localized and (h.Comment like '2' or h.Comment like '7') group by q.Id, q.CreationDate order by q.CreationDate desc ) as x order by NewId()