Skip to content

What authors asked the most questions within a specific discord guild?

Query Name

guild_author_most_question_messages

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)  )
        and msg_content like '%?%'
    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_count desc;