开发者

Could someone write a SE data query for finding Revival candidates? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.

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 question

Could 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. ​

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜