# Data Explorer - Vote count

**URL:** <https://meta.discourse.org/t/data-explorer-vote-count/266441>\
**Category:** Data & reporting\
**Tags:** topic-voting, sql-query\
**Created:** [May 28, 2023, 2:45pm UTC](https://meta.discourse.org/t/data-explorer-vote-count/266441 "2023-05-28T14:45:49Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [May 28, 2023, 3:11pm UTC](https://meta.discourse.org/t/data-explorer-vote-count/266441/2 "2023-05-28T15:11:14Z")

</div>

The Topic Voting tables are `discourse_voting_topic_votes` and `discourse_voting_votes`. You can include the number of votes for each topic with something like this: 👍

```sql

SELECT
    t.id AS topic_id,
    t.title AS topic_title,
    dvtv.votes_count,
    t.excerpt,
    t.like_count,
    ('https://our_community.com/t/' || t.slug || '/' || t.id) AS url
FROM 
    topics t
JOIN 
    discourse_voting_topic_vote_count dvtv ON t.id = dvtv.topic_id
WHERE 
    t.category_id = 95
AND 
    t.created_at > NOW() - INTERVAL '2 years'
AND deleted_at IS NULL

```

There are also a couple more queries you may find useful in the #data-reporting category - [Topics tagged topic-voting](https://meta.discourse.org/tags/c/data-reporting/148/topic-voting)

---

_[View the full topic](https://meta.discourse.org/t/data-explorer-vote-count/266441)._
