Search code examples
dataexplorersede

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


Could someone write a query that filters out 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.


Solution

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