Bad Naruto

3

Please login or register to vote for this query.

(click on this box to dismiss)

Selfie accepted answers with zero or negative score, when there are other answers with positive score. Such answers seem suspicious, and might even need moderator attention. **Warning:** these are *potential* bad Narutos. Legitimate false positives may exist.

Code Review

Q&A for peer programmer code reviews

DECLARE @username AS NVARCHAR(60) = ##DisplayName:string? ##;
DECLARE @userId AS INT = ##UserId:int?-1##;

WITH AcceptedAnswers AS (
  SELECT Id, ParentId, Score, OwnerUserId, CreationDate
  FROM Posts
  WHERE PostTypeId = 2
    AND (@userId < 0 OR OwnerUserId = @userId)
    AND (@username = '' OR OwnerUserId IN (
        SELECT Id
        FROM Users
        WHERE DisplayName = @username))
),

SelfAcceptedQuestions AS (
  SELECT q.Id, q.OwnerUserId, q.CreationDate
  FROM Posts q
    JOIN AcceptedAnswers a ON q.Id = a.ParentId
  WHERE q.AcceptedAnswerId IS NOT NULL
    AND q.AcceptedAnswerId = a.Id
    AND q.OwnerUserId = a.OwnerUserId
    AND a.Score <= 0
)

SELECT TOP ##Limit:int?100##
  q.OwnerUserId [User Link],
  q.Id [Post Link],
  q.CreationDate [Post Date]
FROM SelfAcceptedQuestions q
WHERE EXISTS (
    SELECT Id FROM Posts a 
    WHERE q.Id = a.ParentId
      AND a.Score > 0
  )
ORDER by q.CreationDate DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results