Q&A for professional and enthusiast programmers
WITH Answers AS ( SELECT * FROM Posts WHERE PostTypeId = 2 -- Answers ) SELECT TOP 10 Questions.Id AS [Post Link] FROM Posts AS Questions LEFT OUTER JOIN Answers AS FirstAnswer ON FirstAnswer.ParentId = Questions.Id LEFT OUTER JOIN Answers AS LastAnswer ON LastAnswer.ParentId = Questions.Id LEFT OUTER JOIN Answers AS AcceptedAnswer ON AcceptedAnswer.Id = Questions.AcceptedAnswerId LEFT OUTER JOIN Answers AS BestAnswer ON BestAnswer.Id = Questions.Id WHERE Questions.PostTypeId = 1 -- Questions AND FirstAnswer.Id = ( SELECT TOP 1 Id FROM Answers WHERE Answers.ParentId = Questions.Id ORDER BY CreationDate ASC ) AND LastAnswer.Id = ( SELECT TOP 1 Id FROM Answers WHERE Answers.ParentId = Questions.Id ORDER BY CreationDate DESC ) AND BestAnswer.Id = ( SELECT TOP 1 Id FROM Answers WHERE Answers.ParentId = Questions.Id ORDER BY Score DESC );