# Polls - how to see order of votes

**URL:** <https://meta.discourse.org/t/polls-how-to-see-order-of-votes/70605>\
**Category:** Feature\
**Created:** [9월 22, 2017, 8:05오후 UTC](https://meta.discourse.org/t/polls-how-to-see-order-of-votes/70605 "2017-09-22T20:05:40Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![saurabhp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saurabhp/32/125182_2.png) [@saurabhp](https://meta.discourse.org/u/saurabhp)\
**Post date:** [12월 14, 2018, 5:05오전 UTC](https://meta.discourse.org/t/polls-how-to-see-order-of-votes/70605/6 "2018-12-14T05:05:10Z")

</div>

I was testing this on my system. Votes are already shown in vote order(aka created order). I tried making few polls and seeing their votes, they were shown in vote order itself.

Also from code, I can see that votes are returned in order of created\_at.

Relevant code:

```plaintext
votes = DB.query <<~SQL
            SELECT digest, user_id
              FROM (
                SELECT digest
                     , user_id
                     , ROW_NUMBER() OVER (PARTITION BY poll_option_id ORDER BY pv.created_at) AS row
                  FROM poll_votes pv
                  JOIN poll_options po ON pv.poll_option_id = po.id
                 WHERE pv.poll_id = #{poll.id}
                   AND po.poll_id = #{poll.id}
              ) v
              WHERE row BETWEEN #{offset} AND #{offset + limit}
          SQL

```

and

```plaintext
user_ids = PollVote
            .where(poll: poll, poll_option: poll_option)
            .group(:user_id)
            .order("MIN(created_at)")
            .offset(offset)
            .limit(limit)
            .pluck(:user_id)

```

---

_[View the full topic](https://meta.discourse.org/t/polls-how-to-see-order-of-votes/70605)._
