# Who has been sending the most messages in the last week?

**URL:** <https://meta.discourse.org/t/who-has-been-sending-the-most-messages-in-the-last-week/275007>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [2017年六月5日 15:04 UTC](https://meta.discourse.org/t/who-has-been-sending-the-most-messages-in-the-last-week/275007 "2017-06-05T15:04:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)\
**Post date:** [2017年六月5日 15:04 UTC](https://meta.discourse.org/t/who-has-been-sending-the-most-messages-in-the-last-week/275007/1 "2017-06-05T15:04:05Z")

</div>

### Who has been sending the most messages in the last week?

```sql
SELECT user_id, count(*) AS message_count
FROM topics
WHERE archetype = 'private_message' AND subtype = 'user_to_user'
AND age(created_at) < interval '7 days'
GROUP BY user_id
ORDER BY message_count DESC

```

Useful [for tracking down suspicious PM activity](https://meta.discourse.org/t/who-messaged-the-most/63963).
