QuestionQ73

VerifiedReporting Aggregated Data Using the Group Functions

Review these statements, which execute successfully:

Question Image

Both statements show departments sorted by their average salaries.

Which two statements are true?

Choose two
Explanation

A table alias is usable only in the query block where it is defined. e.avg_sal belongs to the aggregated inline view in the second statement, so it can be selected there, but the e alias inside the first statement’s scalar subquery is not in scope for the outer select list. The first statement retains every row from departments and merely evaluates the correlated average for ordering, whereas the second statement uses an inner join to the employee aggregates and therefore excludes departments with no employees.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!