IMY Learning
Back to Questions

21. Top 5 Countries by Number of Channels

Solution ↗
Medium
Tables: channels
+-------------------------+-------------+
| Column Name             | Type        |
+-------------------------+-------------+
| channel_id              | varchar     |
| channel_name            | varchar     |
| subscriber_count        | bigint      |
| view_count              | bigint      |
+-------------------------+-------------+
channels contains one row per YouTube channel.
channel_id is the primary key for this table.
Write a SQL query to find the top 5 countries having the highest number of channels.
Hint
Tip: Group by country, sort descending, then limit.
Input:
channels table:
+------------+------------------+------------------+------------+
| channel_id | channel_name     | subscriber_count | view_count |
+------------+------------------+------------------+------------+
| C101       | Alpha Tech       | 2500000          | 92000000   |
| C102       | Data With Mira   | 1800000          | 71000000   |
| C103       | SQL Zone         | 950000           | 40000000   |
+------------+------------------+------------------+------------+
Output:
Output:
+---------+----------------+
| country | total_channels |
+---------+----------------+
| US      | 2              |
| IN      | 1              |
+---------+----------------+
Explanation:

Countries are ordered by the number of channels they contain.

SQL Editor
Click "Run SQL" to execute the query and see results here.
About Us Contact Us Privacy Policy Terms & Conditions
© 2026 IMY Learning. All rights reserved.