# View Count of a specific tag

**URL:** https://meta.discourse.org/t/view-count-of-a-specific-tag/275150
**Category:** Data & reporting
**Tags:** tags, sql-query
**Created:** [March 16, 2019, 3:36am UTC](https://meta.discourse.org/t/view-count-of-a-specific-tag/275150 "2019-03-16T03:36:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Viki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/viki/32/131139_2.png) [@Viki](https://meta.discourse.org/u/Viki)
#### Post date: [March 16, 2019, 3:36am UTC](https://meta.discourse.org/t/view-count-of-a-specific-tag/275150/1 "2019-03-16T03:36:29Z")

</div>

How to query the **View counts** of entire Topics with Particular **Tag**?

---

<div class="post-metadata">

### Author: ![SidV](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sidv/32/119460_2.png) [@SidV](https://meta.discourse.org/u/SidV)
#### Post date: [March 16, 2019, 11:41pm UTC](https://meta.discourse.org/t/view-count-of-a-specific-tag/275150/2 "2019-03-16T23:41:17Z")

</div>

> [@Viki](#):
>
> How to query the **View counts** of entire Topics with Particular **Tag**?

I’m not sure, try this:

```sql
-- [params]
-- text :tag_name
SELECT COUNT(tt.tag_id)
FROM topic_tags tt, tags t, topic_views tv, topics tp
WHERE t.id = tt.tag_id
AND tp.id = tt.topic_id
AND tv.topic_id = tp.id 
AND t.name = :tag_name
GROUP BY tt.tag_id

```
