Question in [RANGE] / Accepted Answer / Worst Answer

0

Please login or register to vote for this query.

(click on this box to dismiss)

Martial Arts

Q&A for students and teachers of all martial arts

declare @Start DATETIME = ##PostedAfter:string?2023-01-01##
declare @End DATETIME = ##PostedBefore:string?2023-03-01##

PRINT 'from ' + format(@Start, 'D') + ' to ' + format(@End, 'D')

select q.id AS [Post Link], aa.body AS "Accepted Answer", aa.score AS "Accepted Score", a.body AS "Worst Answer", a.score AS "Worst Score" 
from posts q 
inner join posts aa on q.acceptedanswerid = aa.id --- accepted answer
inner join posts a on (
a.parentid = q.id --- join q's with a's
and a.id != aa.id --- not the accepted answer
and a.score < aa.score --- strictly worse than aa
and a.score = (
        SELECT MIN(Score) --- lowest scoring answer
        FROM Posts a
        WHERE a.ParentId = q.Id 
    )
)
where 
q.creationdate between @Start and @End --- asked in RANGE
and q.posttypeid=1 --- questions
and q.score >= 0 --- positive score
and q.answercount > 1 --- not just accepted answer
and aa.score > 0 --- accepted answer has upvotes
order by aa.score desc
;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results