Kevin Davis
Kevin Davis

Reputation: 365

Oracle SQL Error: ORA-00923: From Keyword not found where expected

When I use the following sql command for Oracle:

SELECT CATEGORY,ANTIGENNAME,LATINCOMPOSITION,HYCORCODE,FDACLEARANCE, LISTAGG(ORCHARDCODE, ';')
    WITHIN GROUP (ORDER BY ORCHARDCODE) as code
from tablename
group by HYCORCODE

I'm seem to be getting a ORA-00923 error:

ORA-00923: FROM keyword not found where expected

What could be causing the error to show up?

Upvotes: 2

Views: 10537

Answers (2)

trincot
trincot

Reputation: 350272

LISTAGG is not available in your version of Oracle. Check your version with this statement:

select * from v$version;

LISTAGG is only available on versions >= 11.2.x

From "Oracle Database 11g Release 2 (11.2) New Features in Data Warehousing":

Analytic Functions

New SQL analytic functions have been introduced that enable you to list (or concatenate) measure values within a group (LISTAGG).

Upvotes: 13

Gordon Linoff
Gordon Linoff

Reputation: 1269803

code is not a reserved word, so I don't think it needs to be quoted (see here).

However, you have an aggregation function, so you need the correct columns in the group by:

SELECT CATEGORY, ANTIGENNAME, LATINCOMPOSITION, HYCORCODE, FDACLEARANCE, 
       LISTAGG(ORCHARDCODE, ';') WITHIN GROUP (ORDER BY ORCHARDCODE) as code
from tablename
group by CATEGORY, ANTIGENNAME, LATINCOMPOSITION, HYCORCODE, FDACLEARANCE;

This definitely fixes a problem with your query. I'm not sure if it will fix your particular error. When I leave out columns from the group by, I get "ORA-00979 (not a GROUP BY expression)."

Upvotes: 0

Related Questions