select sum(case when x.c < 10 or x.c = null then 1 else 0...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Portuguese Language

Q&A for linguists, teachers and learners wanting to discuss the finer points of the Portuguese language

select sum(case when x.c < 10 or x.c = null then 1 else 0 end) as underten,
sum(case when x.c between 10 and 20 then 1 else 0 end) as tentotwenty,
sum(case when x.c > 20 then 1 else 0 end) as overtwenty
from (
select sum(case when posttypes.id = 1 then 1 else 0 end) as c from users
left join posts on posts.owneruserid = users.id
left join posttypes on posttypes.id = posts.posttypeid
group by users.id
) as x

Enter Parameters

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