Percentage of posts from the top 1 percent of posters

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

declare @allPosts decimal(15,5) 
SELECT @allPosts = cast(COUNT(*) as decimal(15,5) ) FROM posts

SELECT  CAST(SUM(k) as decimal (15,5)) / @allPosts * 100
FROM (
SELECT TOP 1 PERCENT OwnerUserID , count(id) k
FROM Posts p
WHERE OwnerUserID > 0
GROUP BY OwnerUserID
ORDER BY count(id) desc ) T

Enter Parameters

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