SELECT q.Id AS [Question Id], q.Title AS [Question Title]...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Genealogy and Family History Meta

Q&A about the site for expert genealogists and people interested in genealogy or family history

-- Select the columns you want to export
SELECT 
    q.Id AS [Question Id], 
    q.Title AS [Question Title], 
    q.Body AS [Question Body], 
    q.Tags AS [Question Tags], 
    q.CreationDate AS [Question Date], 
    q.AcceptedAnswerId AS [Accepted Answer Id], 
    a.Id AS [Answer Id], 
    a.Body AS [Answer Body], 
    a.CreationDate AS [Answer Date]
-- Join the Posts table twice, once for questions and LEFT JOIN for answers
FROM Posts q
LEFT JOIN Posts a ON q.Id = a.ParentId AND a.PostTypeId = 2 -- ensure we're joining with answers
-- Filter to ensure we are selecting questions
WHERE q.PostTypeId = 1 -- question
  AND q.Tags LIKE '%<quantum-computing>%' -- filter by tag
  AND q.CreationDate BETWEEN '2008-08-01' AND '2023-08-31' -- filter by date range
-- Order by whether the question has an accepted answer first, then by the question date
ORDER BY 
    CASE 
        WHEN q.AcceptedAnswerId IS NOT NULL THEN 0 
        ELSE 1 
    END,
    q.CreationDate ASC;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results