Q&A about the site for people studying math at any level and professionals in related fields
/*Show the top 50 ranked questions (post type)
of users with badges only, which were closed in September 2021.*/
-- SELECT count(u.Id),count(DISTINCT u.Id)
-- from Users u
-- INNER JOIN Badges b ON u.Id = b.UserId
-- select DISTINCT b.UserId, CASE
-- WHEN b.UserId IS NOT NULL THEN 1
-- ELSE 0 END AS 'has_badges'
-- from Badges b;
SELECT count(u.Id),count(DISTINCT u.Id)
from Users u
INNER JOIN (select DISTINCT UserId, CASE
WHEN UserId IS NOT NULL THEN 1
ELSE 0 END AS 'has_badges'
from Badges) b ON u.Id = b.UserId