Do you have a positive question record? (based on public information)

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @UserID int = ##UserID:int##, @CountedQs decimal, @QRecord decimal

-- Question record:
-- (total - negative - closed - deleted) / total

SELECT @CountedQs = count(*) -- Getting the top half of the fraction
  FROM Posts
  WHERE PostTypeId = 1      -- It's a question
  AND OwnerUserID = @UserID -- Asked by the user
  AND Score >= 0            -- And positively scored
  AND ClosedDate IS NULL    -- And not closed
  -- As far as I can tell, there's no way to check for deleted questions
  --   so those can't count. Feel free to edit one in if there is.

SELECT @CountedQs / CAST(count(*) AS decimal) -- The top over total
  AS [Score] -- With a fancy name
  FROM Posts
  WHERE PostTypeId = 1      -- It's a question
  AND OwnerUserId = @UserID -- Asked by our user

Enter Parameters

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