Poor Positive Post Rate Count (min 100 Posts)

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

With Cte as (
SELECT
   SUM (CASE WHEN SCORE < 0 THEN 1 ELSE 0 END) NegativePost,
   SUM (CASE WHEN SCORE = 0 THEN 1 ELSE 0 END) ZeroPointPost,
   SUM (CASE WHEN SCORE > 0 THEN 1 ELSE 0 END) PositivePost,
   COUNT (ID) PostCount,
   CAST(SUM (CASE WHEN SCORE > 0 THEN 1 ELSE 0 END) AS DECIMAL) / Count(Id) PositivePostRate,
   OwnerUserID
FROM
   Posts
WHERE 
  OwnerUserID <> -1 --Community user
GROUP BY    
  OwnerUserID
  HAVING COUNT (ID) > 100)
SELECT
  RANK() OVER (ORDER BY PositivePostRate) Rank,
  OwnerUserID [User Link],
  NegativePost,
  ZeroPointPost,
  PositivePost,
  PostCount,
  PositivePostRate
FROM
  cte
ORDER BY 
  PositivePostRate

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached