We’re using categories as a way to stay up to date on certain topics and we are encouraging our users to subscribe/watch the category so they get the information in their email fast.
We want to measure the success of this initiative but we can’t seem to find a way to see how many users are watching a category.
Is this possible? Even if the data is in the database we can pull that would be great.
SELECT c.id as ID,
c.name as NAME,
cu.notification_level as NOTIFICATION_LEVEL,
CASE cu.notification_level
WHEN 0 THEN 'MUTED'
WHEN 1 THEN 'REGULAR'
WHEN 2 THEN 'TRACKING'
WHEN 3 THEN 'WATCHING'
WHEN 4 THEN 'WATHING FIRST POST' END as NOTIFICATION_LEVEL_DESC,
COUNT(cu.id) as COUNT_OF_TYPE
FROM category_users cu
JOIN categories c ON cu.category_id = c.id
GROUP BY c.id, c.name, cu.notification_level, notification_level_desc
ORDER BY c.name, cu.notification_level
Thank you @merefield that got me 90% of what I needed and I was able to update your SQL statement to my needs like so:
SELECT c.name as NAME,
COUNT(cu.id) as subscribers
FROM category_users cu
JOIN categories c ON cu.category_id = c.id
WHERE
c.name LIKE '%Announcements%'
AND
(cu.notification_level = 2
OR
cu.notification_level = 3
OR
cu.notification_level = 4)
GROUP BY c.id, c.name
ORDER BY subscribers DESC, c.name