with cte as ( select id, upvotes, downvotes, upvotes/down...

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

with cte as (
select id, upvotes, downvotes, upvotes/downvotes as ratio
from users
where reputation > 200
and downvotes > 0
)
select sum(case when ratio > 20 then 1 else 0 end) as twenty
, sum(case when ratio > 10 then 1 else 0 end) as ten
, sum(case when ratio > 5 then 1 else 0 end) as five
, sum(case when ratio > 1 then 1 else 0 end) as morethanone
, sum(case when ratio = 5 then 1 else 0 end) as exactlysame
, sum(case when ratio < 1 then 1 else 0 end) as moredown
from cte

Enter Parameters

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