Q&A about the site for operations research and analytics professionals, educators, and students
WITH a AS ( SELECT u.id AS user_id , COUNT(DISTINCT p.id) AS posts FROM Users u LEFT JOIN Posts p ON p.OwnerUserId = u.id AND p.PostTypeId = 2 AND (p.CreationDate>='2023-04-08' AND p.CreationDate<'2023-04-15') GROUP BY u.id ) , total AS ( SELECT COUNT(DISTINCT u.id) AS users FROM Users u ) SELECT COUNT(DISTINCT user_id) AS users , posts FROM a GROUP BY posts