Knowledge Base

Add an alias for the (grouping) column

ORA-00998: must name this expression with a column alias

You are trying to create a view, and are probably using a (grouping) function in the column list.
You did not provide an alias to this function, which results in this error.

Oracle tries to map the function name into a valid column name, but is not able to do so.
That’s why it is asking to provide an alias:

SQL> create or replace view v as select dummy, count(*) from dual group by dummy;
create or replace view v as select dummy, count(*) from dual group by dummy
                                          *
ERROR at line 1:
ORA-00998: must name this expression with a column alias

When we provide an alias for the function, it is able to create the view:

SQL> create or replace view v as select dummy, count(*) cnt from dual group by dummy;

View created.

Oracle Gold Partner DbMotive is an Oracle Gold Partner