Return a single value from a nested query.
Section: Subqueries
Scalar subquery
sql
sql
SELECT employee_id, salary,
(SELECT AVG(salary) FROM employees) AS avg_salary
FROM employees;Explanation
A scalar subquery must return at most one row.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Subqueries