17. Maximum and Minimum Subscribers
Solution ↗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 return the maximum and minimum subscriber counts from the channels table.
Hint
Tip: Use aggregate functions together.
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: +-----------------+-----------------+ | max_subscribers | min_subscribers | +-----------------+-----------------+ | 2500000 | 950000 | +-----------------+-----------------+
Explanation:
The query returns the largest and smallest subscriber counts.