Skip to content

When was the most active month for the most active channel in each discord guild?


select guilds_t.id as guild_id, guilds_t.guild_name, channels_t.id as channel_id, channels_t.channel_name, month_timestamp, count from (
    select
        DATE_TRUNC('month', real_timestamp)
                     AS  month_timestamp,
        COUNT(channel_id) AS count,
        channel_id
    FROM messages_t
    GROUP BY channel_id, month_timestamp
) as month_messages_t
join channels_t on month_messages_t.channel_id = channels_t.id
join guilds_t on channels_t.guild_id = guilds_t.id
order by guilds_t.id, month_timestamp;