Which of my answers are for questions without an accepted answer?

2

Please login or register to vote for this query.

(click on this box to dismiss)

This is the greedy-for-acceptance query. Finds your answers for questions where the asker hasn't accepted an answer and has a low acceptance rate and the user has been active in the last few months. Results are ordered by the asker's last activity date and acceptance rate.

Emacs

Q&A for those using, extending or developing Emacs

-- Which of my answers are for questions without an accepted answer?
-- This is the greedy-for-acceptance query.
-- Finds your answers for questions where the asker hasn't accepted an answer
-- and has a low acceptance rate and the user has been active in the last
-- few months. Results are ordered by the asker's last activity date and
-- acceptance rate.

DECLARE @UserId int = ##UserId##
DECLARE @MaxAcceptanceRate float = ##MaxAcceptanceRate:float##
DECLARE @LastActiveIn int = ##ActiveInTheLastNMonths:int##

SELECT 
      MIN(a.Id) AS [Post Link], MIN(a.CreationDate) AS CreationDate,
      u.Id AS [User Link], ar.[Accept Rate], u.LastAccessDate AS [Last Questioner Appearance]
  FROM
      Posts AS a
    JOIN
      Posts AS q ON a.ParentId = q.Id
    JOIN
      Users AS u ON q.OwnerUserId=u.Id
    JOIN (
      SELECT
        Sum(CASE WHEN q.AcceptedAnswerId IS NULL THEN 0 ELSE 1 END) / Cast(COUNT(DISTINCT q.Id) AS Float) AS [Accept Rate],
        Count(DISTINCT q.Id) AS [Total Questions],
        q.OwnerUserId
      FROM
          posts AS q
      WHERE q.PostTypeId=1
        AND q.OwnerUserId != 1 
        AND DATEDIFF(day, q.CreationDate, GETUTCDATE()) > 3
      GROUP BY q.OwnerUserId
      HAVING Count(DISTINCT q.Id) >=4
    ) AS ar ON q.OwnerUserId=ar.OwnerUserId
  WHERE
      q.AcceptedAnswerId IS NULL
    AND a.OwnerUserId = @UserId
    AND @MaxAcceptanceRate >= ar.[Accept Rate]
    AND DATEDIFF(month, u.LastAccessDate, GETUTCDATE()) <= @LastActiveIn
GROUP BY u.Id, ar.[Accept Rate], u.LastAccessDate, ar.[Total Questions]
ORDER BY [Last Questioner Appearance] DESC, [Accept Rate] ASC

Enter Parameters

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