Skip to content

Who sent the most attachments in a specific discord guild?

Query Name

guild_author_most_attachments

SQL Query


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