
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.
| 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 |
| 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 |
| user_id | message_count |
|---|---|
| 1007 | 2 |
| 1001 | 1 |
| Column | Type | Description |
|---|---|---|
| interaction_idPK | INT | Unique interaction event ID |
| user_id | INT | User who performed the interaction |
| event_type | VARCHAR(50) | Interaction type such as message sent or voice channel joined |
| channel_id | INT | Associated text or voice channel ID |
| event_ts | TIMESTAMP | Timestamp of the interaction |
| 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 |
| 106 | 1003 | message_sent | 504 | 2024-05-03 10:05:00 |
| 107 | 1003 | voice_channel_joined | 702 | 2024-05-03 10:06:00 |
| 108 | 1004 | voice_channel_joined | 703 | 2024-05-03 10:07:00 |
| 109 | 1005 | reaction_added | 505 | 2024-05-03 10:08:00 |
| 110 | 1006 | 2024-05-03 10:09:00 | ||
| 111 | 1002 | message_sent | 506 | 2024-05-03 10:10:00 |
| 112 | 1008 | message_sent | 0 | 2024-05-03 10:11:00 |
| 1 | 3 | thread_joined | null | 2024-04-30 15:38:15 |
| 2 | 78 | reaction_added | 74 | 2024-05-02 13:25:44 |
| 3 | 69 | presence_updated | 33 | 2024-05-04 18:51:34 |
| 4 | 24 | message_sent | 52 | 2024-05-02 20:31:58 |
| 5 | 32 | voice_channel_left | 11 | 2024-05-03 14:27:46 |
| 6 | 47 | screen_share_started | 19 | 2024-05-04 18:03:17 |
| 7 | 12 | null | 87 | 2024-05-03 08:13:02 |
| 8 | 45 | stream_stopped | null | 2024-05-01 10:04:04 |
| 9 | 22 | message_deleted | 74 | 2024-05-01 07:53:41 |
| 10 | 10 | presence_updated | 63 | 2024-05-02 09:58:08 |
| 11 | 18 | presence_updated | null | 2024-05-02 09:09:18 |
| 12 | 31 | thread_joined | 95 | 2024-05-01 03:53:59 |
| 13 | 13 | channel_viewed | 42 | 2024-05-04 16:36:58 |
| 14 | 75 | friend_request_accepted | 29 | 2024-05-03 20:17:17 |
| 15 | 99 | stream_stopped | 94 | 2024-05-01 14:25:39 |
| 16 | 87 | channel_viewed | 88 | 2024-04-30 16:42:31 |
| 17 | 10 | voice_channel_joined | 17 | 2024-05-02 21:21:25 |
| user_id | message_count |
|---|---|
| 1007 | 2 |
| 24 | 1 |
| 1001 | 1 |
| 1008 | 1 |