May 2020
Beginner
564 pages
14h 9m
English
To help you better understand how to use a non-correlated subquery in the FROM clause, execute the following query:
USE lahmansbaseballdb; SELECT ROUND(AVG(average_salary), 0) AS average_of_all_teams_salariesFROM (SELECT AVG(salary) average_salary FROM salaries GROUP BY teamid);
The preceding query will give you the following error:
Error Code: 1248. Every derived table must have an alias.
This means that we need to add an alias to the inner query contained in the FROM clause. The subquery used in a FROM clause is also referred to as a derived table. The following highlighted code shows you a proper derived table, along with its alias:
Subquery and derived table terminology are often ...
Read now
Unlock full access