Intercom – Min, Max and Average Messages per Conversation

Question

What is the minimum, maximum and the average number of messages exchanged between our customer and support team?

Schema

Intercom

Output

 

Intercom - Min, Max and Average Messages per Conversation

SQL Query

SELECT min(total_messages) AS MIN,
       max(total_messages) AS MAX,
       avg(total_messages) AS average
FROM
  (SELECT conversation_id,
          count(id) AS total_messages
   FROM conversations_parts
   GROUP BY conversation_id
   ORDER BY total_messages DESC) messages_metrics

in Customer Support