WITH a AS ( SELECT Year(CreationDate) AS QuestionYear, CA...

0

Please login or register to vote for this query.

(click on this box to dismiss)

GIS

Q&A for cartographers, geographers and GIS professionals

WITH a AS (
SELECT
Year(CreationDate) AS QuestionYear,
CASE WHEN p.AnswerCount > 0 THEN 'Y' ELSE 'N' END AS Answers,
COUNT(*) AS ClosedQuestions
FROM PostsWithDeleted p
WHERE ClosedDate IS NOT NULL
  AND p.PostTypeId = 1
GROUP BY
  Year(CreationDate),
  CASE WHEN p.AnswerCount > 0 THEN 'Y' ELSE 'N' END
  )
SELECT
  QuestionYear, N AS NoAnswers, Y AS Answers
FROM a
PIVOT (SUM(ClosedQuestions) FOR Answers IN (N,Y)) AS ap

Enter Parameters

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