Question distribution by number of views

1

Please login or register to vote for this query.

(click on this box to dismiss)

Which questions have the most views and which the smallest, summed into 'buckets'

Stack Overflow

Q&A for professional and enthusiast programmers

-- Question distribution by number of views
-- Which questions have the most views and which the smallest, summed into 'buckets'

select
    sum(case when ViewCount > 100000 then 1 end) as PopPosts,
    sum(case when ViewCount <= 100000 and ViewCount > 50000 then 1 end) as HugePosts,
    sum(case when ViewCount <= 50000 and ViewCount > 10000 then 1 end) as LargePosts,
    sum(case when ViewCount <= 10000 and ViewCount > 5000 then 1 end) as MedPosts,
    sum(case when ViewCount <= 5000 and ViewCount > 2500 then 1 end) as RegPosts,
    sum(case when ViewCount <= 2500 and ViewCount > 1000 then 1 end) as SmallPosts,
    sum(case when ViewCount <= 1000 and ViewCount > 500 then 1 end) as TinyPosts,
    sum(case when ViewCount <= 500 and ViewCount > 300 then 1 end) as MiniPosts,
    sum(case when ViewCount <= 300 and ViewCount > 100 then 1 end) as MicroPosts,  
    sum(case when ViewCount <= 100 then 1 end) as ForgottenPosts
    
FROM
     Posts p
WHERE
    p.ParentId is null

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results