Questions in Dec 2020 where Max Score is higher than Accepted ANswer score where Accepted AnswerScor

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

;WITH DecQnA AS 
(
SELECT
   q.Id QuestionId
   ,q.Title Title
   ,CASE WHEN a.Id = q.AcceptedAnswerId THEN a.Score ELSE NULL END AcceptedAnswerScore
   ,CASE WHEN a.Id = q.AcceptedAnswerId THEN 1 ELSE 0 END IsAcceptedAnswer
   ,a.Id AnswerId
   ,a.Score AnswerScore
FROM
   dbo.Posts q
   INNER JOIN dbo.PostTypes pt ON pt.Id = q.PostTypeId AND pt.Name = 'Question'
   INNER JOIN dbo.Posts a ON a.ParentId = q.Id
   INNER JOIN dbo.PostTypes apt ON apt.Id = a.PostTypeId and pt.Name = 'Answer'
WHERE
   q.CreationDate BETWEEN '2020-12-01' AND '2020-12-31'
AND q.AcceptedAnswerId IS NOT NULL
)
SELECT 
   * 
FROM 
   DecQnA

Enter Parameters

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