Knowing the number of watchers

This is very useful, thanks @MarkDoerr. I modified the query to report on all four notification levels in one pass, and to take an array of topic_ids if needed.
The full grid output table isn’t pretty but has all the info I need.

edit: of course as soon as I posted, Discourse kindly showed me six links with other ways of solving this! Query on!

SELECT 
  topic_id,
  notification_level,
  COUNT(CASE WHEN notification_level = 0 THEN topic_id END) AS Muted_0,
  COUNT(CASE WHEN notification_level = 1 THEN topic_id END) AS Normal_1,
  COUNT(CASE WHEN notification_level = 2 THEN topic_id END) AS Tracking_2,
  COUNT(CASE WHEN notification_level = 3 THEN topic_id END) AS Watching_3
FROM 
  topic_users 
WHERE 
  topic_id IN (9831, 9572, 9424, 7567) -- Add your topic_ids here
GROUP BY
  topic_id, notification_level
1 Like