QuestionQ246

VerifiedReporting Aggregated Data Using the Group Functions

Examine the data in the EMP table:

Question Image

You run the following query:

Question Image

Why does this generate an error?

Explanation

In Oracle Database releases before 23, a column alias defined in the SELECT list can be referenced by the ORDER BY clause, but not by other clauses in the query. Therefore, GROUP BY "Department" is invalid because "Department" is a select-list alias; the grouping must use the underlying deptno expression instead. Quoted aliases may contain spaces.

Learn more

Community Discussion

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