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.
-
Actually, I am looking for questions with any number of votes and answers, but none of the answers may exceed one score. This says that the question may have no answers, and regulates the question's score instead of the answers' scores. I just don't know how to make
answer score = <2
a criterion. Because I'm not a programmer; just an SE geek. – Daniel Sep 1 '11 at 21:03 -
Ah, a WHERE NOT EXISTS would do it. I'm on mobile. I'll update in a bit. – vcsjones Sep 1 '11 at 21:26
-
1Updated. Give that a shot. The badge doesn't seem to care of there any of the existing questions (even with a score of 1) are an accepted answer. If that proves problematic, you can add
AcceptedAnswerId IS NULL
to the (outer) WHERE clause. – vcsjones Sep 1 '11 at 22:18