Q&A for science fiction and fantasy enthusiasts
SELECT q.Id AS [Question ID], q.Title AS [Question Title], q.Body AS [Question Body], a.Id AS [Answer ID], a.Body AS [Answer Body], qc.Text AS [Question Comment], ac.Text AS [Answer Comment], CASE WHEN qc.PostId IS NOT NULL THEN 'Question' ELSE 'Answer' END AS [Comment Type], -- Determine if comment is for a question or answer t.TagName AS [Tag], q.CreationDate AS [Question Date], a.CreationDate AS [Answer Date], a.Score AS [Answer Score] FROM Posts q JOIN PostTags pt ON q.Id = pt.PostId JOIN Tags t ON pt.TagId = t.Id LEFT JOIN Posts a ON q.Id = a.ParentId -- Join answers with their parent questions LEFT JOIN Comments qc ON q.Id = qc.PostId -- Join comments on questions LEFT JOIN Comments ac ON a.Id = ac.PostId -- Join comments on answers WHERE t.TagName LIKE '%youtube-api%' OR t.TagName LIKE '%youtube-data-api%' AND a.PostTypeId = 2 -- PostTypeId = 2 refers to answers ORDER BY q.CreationDate DESC