May 2020
Beginner
564 pages
14h 9m
English
To help you better understand how to use a non-correlated subquery in the SELECT clause, execute the following query:
USE lahmansbaseballdb; SELECT playerid, yearid, salary, (SELECT ROUND(AVG(salary), 0) FROM salaries) AS average_salary, salary - (SELECT ROUND(AVG(salary), 0) FROM salaries) AS difference, (SELECT MAX(salary) FROM salaries) AS max_salaryFROM salariesORDER BY playerid, yearid;
The preceding query returns the results shown in the following screenshot:

The previous query will return the playerid, yearid, salary, average_salary, difference, and max_salary columns for each ...
Read now
Unlock full access