12

I'd like to search for questions that have a positive score (score > 0) and have no accepted answer and have at least one answer and where all answers have score zero. Is there a way to do this?

Motivation: On one site where I'm active, it's semi-common for new users to drop by, ask a question, and eventually get a useful answer that they don't ever accept or upvote. It can be demoralizing for answers to put in a bunch of effort to answer the question but never receive any appreciation for their answer. The ideal answer is for someone else to upvote the useful answer when it appears, but I don't always catch the answer when it is originally posted. I'd like to search for those sort of answers so that I can take a look at them, and if they're useful and answer the question, upvote them. However, I can't figure out a search query that will let me find those answers.

The problem is that my criteria involves conditions on both the score of the question and the score of the answer. I can't see any way to frame a search query that will let me include both kinds of conditions. I can see how to search for questions with a positive score (score:1+ is:question) and how to search for answers with a zero score (score:0 is:answer) but not to search for zero-score answers where the corresponding question has a positive score. I can even see how to incorporate the requirement that the answer not be accepted (score:1+ is:question hasaccepted:no or score:0 is:answer isaccepted:no), but still can't see how to incorporate the condition on both answer score and question score. I also tried score:1+ isanswered:no is:question, which looked promising, but this search results include: (a) questions with zero score, and (b) questions with an accepted answer; so it doesn't do what I'm looking for either. Given the search help, score:1+ isanswered:no hasaccepted:no answers:1+ is:question looked promising too, but this returns mostly questions with no answers (and questions with negatively-scored answers).

So, is there a way to do a search of the sort I want? Can one include both a condition on question score and a condition on answer score?

1
  • 1
    It's not as good for your purposes as search because of the inherent delay, but you could use SEDE to find older ones while you're waiting. Commented Jul 29, 2015 at 16:52

1 Answer 1

2

I used SEDE to answer your question. The following query does what you want:

select top 1000  
       q.id as [Post Link]
     , q.score [question score]
     , q.answercount
     , q.creationdate
from posts q 
where q.score > 0               -- positive scoring question
and q.answercount > 0           -- with at least one answer
and q.acceptedanswerid is null  -- no accepted answer
and (select count(*) 
     from posts 
     where posttypeid = 2
     and parentid = q.id
     and score  = 0) = q.answercount -- all answers score zero
order by q.creationdate desc

If you run this on a small site you might want to remove the top 100, otherwise it limits the result to the most recent 100 answers matching the criteria.

When run today you'll get this result on Stack Overflow:

query result

Keep in mind SEDE is only updated once a week, on Sunday. Have a look at the tutorial and say Hi in SEDE Chat

2
  • Thanks for taking the time to write this code! Unfortunately it doesn't seem to work right. It searches for positive-scoring questions that contain at least one answer with score zero. That's not what I was asking for; I was asking for positive-scoring questions where all answers have score zero, and there's at least one answer (and no accepted answer). For instance, on SO, the results include stackoverflow.com/q/38176472/781723, which has a positive-score answer and a zero-scoring answer.
    – D.W.
    Commented Jul 3, 2017 at 1:25
  • @D.W. I've addressed the issue in an update of the query. It took a bit more then 6 to 8 weeks ...
    – rene Mod
    Commented Aug 21, 2018 at 7:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .