Q&A about the site for people who build and repair bicycles, people who train cycling, or commute on bicycles
with user_post_counts as ( select u.Id, count(p.Id) AS post_count from users u left JOIN posts p ON u.Id = p.OwnerUserId group by u.Id ) select kategorie, count(1) as pocet, round(100.0 * count(1) / (select count(1) from user_post_counts), 2) as procento from ( select case when post_count = 0 then '0' when post_count between 1 and 10 then '1-10' else '>10' end as kategorie, Id from user_post_counts ) as pom group by kategorie order by case kategorie when '0' then 1 when '1-10' then 2 when '>10' then 3 end;