Could someone write a SE data query for finding Revival candidates? [closed]
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this questionCould someone write a query that filters o开发者_如何学运维ut all questions except those which are >30 days old and with no answers that have 2 score or more? I posted this question on meta, and someone suggested I ask it here.
This seems to work:
SELECT TOP 100
p.Id AS [Post Link],
p.*
FROM
Posts p
WHERE
p.PostTypeId = 1
AND
p.CreationDate < GETDATE() - 30
AND
p.ClosedDate IS NULL
AND NOT EXISTS
(
SELECT *
FROM Posts p2
WHERE p2.ParentId = p.Id
AND p2.Score >= 2
AND p2.PostTypeId = 2
)
ORDER BY
p.CreationDate DESC
I also added a criteria to not include questions that are closed.
精彩评论