Skip to content

What is the average message count per Channel in a particular Discord Guild?

SQL Query


select
    guilds_t.guild_name,
    avg(msg_count) as average_channel_length,
    guilds_t.id
from
(
    select
        guild_id,
        channel_id,
        count(content) as msg_count
    from
        messages_t
    where
        guild_id in (  (select id from guilds_t limit 1)  )
        and messages_t.isbot = 'F'
    group by guild_id,channel_id
) as author_in_channel_count_t
join channels_t on author_in_channel_count_t.channel_id = channels_t.id
join guilds_t on channels_t.guild_id = guilds_t.id
group by guilds_t.id;