Subquery in FROM
A subquery in FROM acts as a temporary table and needs an alias.
Example
SELECT country, n FROM (
SELECT country, COUNT(*) AS n FROM students GROUP BY country
) t
WHERE n > 1;Result
country | n Ghana | 2 Nigeria | 4
Exercise
Alias the subquery.
FROM (SELECT 1 a) Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.