Q&A about the site for enthusiasts and scholars of mythology and folklore
SELECT CASE WHEN DATEDIFF(HOUR, q.CreationDate, a.CreationDate) <= 1 THEN '1 hour or less' WHEN DATEDIFF(HOUR, q.CreationDate, a.CreationDate) <= 5 THEN '1-5 hours' WHEN DATEDIFF(HOUR, q.CreationDate, a.CreationDate) <= 24 THEN '5-24 hours' WHEN DATEDIFF(DAY, q.CreationDate, a.CreationDate) <= 7 THEN '1-7 days' ELSE 'More than 7 days' END AS TimeRange, COUNT(*) AS SolvedQuestionsCount FROM Posts q JOIN Posts a ON q.AcceptedAnswerId = a.Id -- Join to link questions with their accepted answers WHERE q.PostTypeId = 1 -- Filter for questions GROUP BY CASE WHEN DATEDIFF(HOUR, q.CreationDate, a.CreationDate) <= 1 THEN '1 hour or less' WHEN DATEDIFF(HOUR, q.CreationDate, a.CreationDate) <= 5 THEN '1-5 hours' WHEN DATEDIFF(HOUR, q.CreationDate, a.CreationDate) <= 24 THEN '5-24 hours' WHEN DATEDIFF(DAY, q.CreationDate, a.CreationDate) <= 7 THEN '1-7 days' ELSE 'More than 7 days' END ORDER BY SolvedQuestionsCount DESC;