# Sabendo o número de observadores

**URL:** <https://meta.discourse.org/t/knowing-the-number-of-watchers/190941>\
**Category:** Feature\
**Tags:** data-explorer, sql-query\
**Created:** [Maio 19, 2021, 4:37pm UTC](https://meta.discourse.org/t/knowing-the-number-of-watchers/190941 "2021-05-19T16:37:40Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![NiceOldGuy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/niceoldguy/32/326207_2.png) [@NiceOldGuy](https://meta.discourse.org/u/NiceOldGuy)\
**Post date:** [Abril 17, 2024, 5:27pm UTC](https://meta.discourse.org/t/knowing-the-number-of-watchers/190941/11 "2024-04-17T17:27:29Z")

</div>

Isso é muito útil, obrigado @MarkDoerr. Modifiquei a consulta para relatar todos os quatro níveis de notificação em uma única passagem e para aceitar uma matriz de `topic_id`s, se necessário.  
A tabela de saída completa da grade não é bonita, mas tem todas as informações de que preciso.

editar: claro, assim que postei, o Discourse gentilmente me mostrou seis links com outras maneiras de resolver isso! Continue a consulta!

```plaintext
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) -- Adicione seus topic_ids aqui
GROUP BY
  topic_id, notification_level

```

---

_[View the full topic](https://meta.discourse.org/t/knowing-the-number-of-watchers/190941)._
