简体   繁体   中英

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. What could be causing the error to show up?

Thank you...

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 ).

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)."

Could be related to the indentifier try using "code"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM