문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top