Skip to content

Order discord Guild's by the oldest message?

Data Visualization

SQL Query


select 
    guilds_t.guild_name,
    time_sorted_messages_t.guild_id,channels_t.channel_name,
    channel_id, content,
    time_sorted_messages_t.real_timestamp 
from 
    messages_t
join 
(
    SELECT guild_id, MIN(msg_timestamp) as real_timestamp 
    FROM messages_t
    GROUP BY guild_id
) as time_sorted_messages_t
on time_sorted_messages_t.real_timestamp = messages_t.msg_timestamp
join guilds_t on time_sorted_messages_t.guild_id = guilds_t.id
join channels_t on messages_t.channel_id = channels_t.id
order by real_timestamp ASC;

GraphQL Query


query MyQuery {
  allMessagesTs(first: 10, orderBy: UNIX_TIMESTAMP_ASC) {
    edges {
      node {
        channelsTByChannelId {
          id
          channelName
        }
        guildsTByGuildId {
          guildName
          id
        }
        realTimestamp
      }
    }
  }
}

Similar Queries