WITH Prep AS ( SELECT Users.Id, CASE WHEN COUNT(p.Id) = 0...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Game Development Meta

Q&A about the site for professional and independent game developers

WITH Prep AS (
  SELECT
    Users.Id,
    CASE
      WHEN COUNT(p.Id) = 0 THEN '0'
      WHEN COUNT(p.Id) >= 1 AND COUNT(p.Id) <= 10 THEN '1-10'
      ELSE '>10'
    END AS Category
  FROM Users
  LEFT JOIN Posts p ON p.OwnerUserId = Users.Id
  GROUP BY Users.Id
)

SELECT
  Category,
  ROUND(100.*COUNT(DISTINCT(Id))/(SELECT COUNT(DISTINCT(Id)) FROM USERS), 2) AS Percentage,
  COUNT(DISTINCT(Id)) AS 'Count'
FROM Prep
  GROUP BY Category

Enter Parameters

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