Skip to content

How many messages has a user posted in each discord channel of a particular discord guild?

Query Name

count_messages_per_channel_for_user_in_guild

SQL Query

"arg_order" : ["guild_id", "author_id", "author_id"]


select
  author_channel_msg_count_t.channel_id,
  channels_t.channel_name,
  authors_t.author_name,
  authors_t.nickname,
  msg_count,
  guilds_t.guild_name,
  authors_t.id as authors_guild_id,
  guilds_t.id
from
(
  select
    count(*) as msg_count,
    channel_id
  from
    messages_t
  where
    guild_id = '{}'
    and author_guild_id = '{}'
  group by channel_id
) as author_channel_msg_count_t
join channels_t on author_channel_msg_count_t.channel_id = channels_t.id
join authors_t on '{}' = authors_t.id
join guilds_t  on guilds_t.id = authors_t.guild_id
order by msg_count desc;


Similar Queries