# أبحث عن شارات جيدة تتعلق بالتصويت

**URL:** <https://meta.discourse.org/t/looking-for-some-good-badges-related-to-voting/116086>\
**Category:** Data & reporting\
**Tags:** badges, topic-voting, sql-query\
**Created:** [26 أبريل 2019، 6:29م UTC](https://meta.discourse.org/t/looking-for-some-good-badges-related-to-voting/116086 "2019-04-26T18:29:13Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Marc\_Montecalvo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marc_montecalvo/32/160134_2.png) [@Marc\_Montecalvo](https://meta.discourse.org/u/Marc_Montecalvo)\
**Post date:** [29 أبريل 2019، 12:45م UTC](https://meta.discourse.org/t/looking-for-some-good-badges-related-to-voting/116086/6 "2019-04-29T12:45:01Z")

</div>

That got me quite a ways towards my target:

```plaintext
select    
    t.user_id,
    ucf.value,
    count(*)
from
    topics t
    join user_custom_fields ucf on t.id = cast(ucf.value as int)
where ucf.name = 'votes'
group by ucf.value, t.user_id
order by t.user_id, count(*) desc

```

That returns:

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/2/c29f1391e7f38e488178642798018c879f2eb4c8.png)

The two things I’m trying to get are total votes someone got and the topic that has the most votes for each person. You can see mmontecalvo has 2 topics showing. I’m fairly certain I need to use `row_number()` to get just the highest post but I don’t know how.

@codinghorror These may be similar to a default badge but none of the defaults are built off topics getting votes.

---

_[View the full topic](https://meta.discourse.org/t/looking-for-some-good-badges-related-to-voting/116086)._
