A subquery selects rows from one table based on values
in another table. Subqueries are also known as nested
queries or inner queries.
A subquery is a query expression that is
nested as part of another query expression. Depending on the clause
that contains it, a subquery can return a single value or multiple
values. Subqueries are most often used in WHERE and HAVING clauses.
Subqueries are enclosed in parentheses.
The following PROC SQL
query contains a subquery in the HAVING clause that returns all jobcodes
where the average salary for that jobcode is greater than the company
average salary.
proc sql; select jobcode, avg(salary) as AvgSalary format=dollar11.2 from ...