Q&A for professional robotic engineers, hobbyists, researchers and students
select case WHEN cnt_post.cnt_post = 0 THEN '0' WHEN cnt_post.cnt_post between 1 AND 10 THEN '1- 10' WHEN cnt_post.cnt_post > 10 THEN '> 10' END as vysledek -- (count(*) *100/ total.total_user) as procento from users u join (select count(*) as cnt_post,users.id as onwerid from users left join posts p on users.id = p.owneruserid group by users.id) cnt_post on u.id = cnt_post.onwerid --(select count(*) as total_user from users) total group by case WHEN cnt_post.cnt_post = 0 THEN '0' WHEN cnt_post.cnt_post between 1 AND 10 THEN '1- 10' WHEN cnt_post.cnt_post > 10 THEN '> 10' END