MEDIUMVerified Real Interview• Product Analytics Engineer

User Direct Message Volume & Word Counts

Meta Messenger team is analyzing user communication frequency.

Write a SQL query to calculate:

  1. sender_id
  2. Total messages sent (total_messages)
  3. Total words sent across all messages (total_words)
  4. Average words per message rounded to 1 decimal place (avg_words_per_message)

Only include users who sent at least 3 messages. Sort by total_words descending.

Tables:

  • messages (message_id INT, sender_id INT, receiver_id INT, word_count INT, sent_time TIMESTAMP)

Execution Sandbox:

Your query executes inside an isolated in-memory PostgreSQL engine (PGlite WebAssembly). You have full access to standard PostgreSQL aggregations, window functions, and CTEs.

Standard SQL (ANSI)|Ln 1, Col 1
⌘↵ Run Query
Ready to execute. Press Run (⌘+Enter)
Write your query and click “Run” or press ⌘+Enter to inspect output.