Skip to content

How many messages per author in a specific discord guild?

Query Name

guild_author_most_messages

SQL Query


select
    authors_t.author_name,
    authors_t.nickname,
    msg_count_per_author_t.msg_count,
    msg_count_per_author_t.author_guild_id,
    guilds_t.guild_name,
    guilds_t.id as guild_id
from
(
    select
        count(*) as msg_count,
        author_guild_id
    from
        messages_t
    where 
        guild_id in (  (select id from guilds_t limit 1)  )
    group by author_guild_id
    order by msg_count desc
) as msg_count_per_author_t
join authors_t on msg_count_per_author_t.author_guild_id = authors_t.id
join guilds_t  on authors_t.guild_id = guilds_t.id
order by msg_count_per_author_t.msg_count desc;