chat_messages(message_id, sender_id, sent_at)
Return the five busiest senders in the 30 days up to and including 2026-09-30, which means from 2026-09-01 onward.
Return sender_id and message_count, most messages first, breaking ties by
the lower sender_id, and at most five rows.
Tables
chat_messages
message_id sender_id sent_at
---------- --------- -------------------
1 1 2026-09-02 10:00:00
2 1 2026-09-03 10:00:00
3 1 2026-09-04 10:00:00
4 2 2026-09-02 10:00:00
5 2 2026-09-03 10:00:00
6 3 2026-09-05 10:00:00
7 3 2026-09-06 10:00:00
8 4 2026-09-07 10:00:00
... 6 more row(s)
Expected result
sender_id message_count
--------- -------------
1 3
2 2
3 2
4 1
5 1
Sign in to write and run your own code.
SELECT query