Skip to content

What discord user has the longest average message length in a particular guild?

Query Name

user_longest_avg_msg_length

SQL Query


select 
    authors_t.author_name,
    authors_t.nickname,
    avg_content_length_t.content_length,
    avg_content_length_t.content_count,
    authors_t.id
from 
(
    select 
        author_guild_id, 
        count(msg_content_length) as content_count,
        AVG(msg_content_length) as content_length
    from
        messages_t
    where
        is_bot = false
        and guild_id in (  (select id from guilds_t limit 1)  )
    group by author_guild_id
) as avg_content_length_t
join authors_t
on authors_t.id = avg_content_length_t.author_guild_id
order by avg_content_length_t.content_length desc;

Similar Queries