Task
You are given a Discord-style event log that records user actions across surfaces such as text chat and voice. Write a SQL query to return the users who have sent at least one message but have never joined a voice channel.
Use only the user_interactions table. Your result should include each qualifying user_id, the number of message events they generated, and be ordered by message count descending and then user_id ascending.
Schema
| column_name | type | description |
|---|
| interaction_id | INT | Unique event identifier |
| user_id | INT | Discord user identifier |
| event_type | VARCHAR(50) | Type of interaction such as message_sent or voice_channel_joined |
| channel_id | INT | Channel where the interaction happened; may be NULL |
| event_ts | TIMESTAMP | Time of the interaction |
Sample data
| interaction_id | user_id | event_type | channel_id | event_ts |
|---|
| 101 | 1007 | message_sent | 501 | 2024-05-03 10:00:00 |
| 102 | 1002 | voice_channel_joined | 701 | 2024-05-03 10:01:00 |
| 103 | 1001 | message_sent | 502 | 2024-05-03 10:02:00 |
| 104 | 1007 | message_sent | 503 | 2024-05-03 10:03:00 |
| 105 | 1001 | reaction_added | 502 | 2024-05-03 10:04:00 |
Expected output
| user_id | message_count |
|---|
| 1007 | 2 |
| 1001 | 1 |