# Tracking topic views history

**URL:** <https://meta.discourse.org/t/tracking-topic-views-history/280759>\
**Category:** Data & reporting\
**Created:** [October 2, 2023, 4:01pm UTC](https://meta.discourse.org/t/tracking-topic-views-history/280759 "2023-10-02T16:01:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)\
**Post date:** [October 2, 2023, 4:10pm UTC](https://meta.discourse.org/t/tracking-topic-views-history/280759/2 "2023-10-02T16:10:18Z")

</div>

Hi @Ayelen_Rives 👋

Maybe try this:

```sql
-- [params]
-- int :topic_id = 
-- date :start_date = 
-- date :end_date = 

SELECT COUNT(*) AS views
FROM topic_views
WHERE topic_id = :topic_id
AND viewed_at BETWEEN :start_date AND :end_date

```

you will need to specify the topic id (from the topic URL) and the date range parameters in YYYY-MM-DD format.

---

_[View the full topic](https://meta.discourse.org/t/tracking-topic-views-history/280759)._
