ORA-00933错误求助:含子查询的SQL命令未正确结束
Fixing ORA-00933: SQL command not properly ended for your query
Hey there! Let's sort out that ORA-00933 error you're facing. The root cause here is an invalid alias assigned to your subquery—Oracle doesn't allow aliases that include schema names (the dot-separated abc_mgr. part). Aliases need to be simple, single identifiers without dots, which was throwing off the SQL parser.
Here's the corrected version of your query:
select lt.* from ( select abc_mgr.ldap_test.* from abc_mgr.ldap_test order by (case STATUS when 'ACTV' then 1 when 'NOTACTIV' then 2 WHEN 'DIS' then 3 else 4 END), (case BILL_SYS when 'V' then 1 when 'S' then 2 when 'E' then 3 else 4 END) ) lt where rownum = 1;
Key changes made:
- Replaced the invalid subquery alias
abc_mgr.ldap_testwith a simple, valid aliaslt. This removes the parsing confusion between the actual table name and the subquery alias. - Kept all your original sorting logic and
rownum = 1filter intact, so you'll still get the first row after applying your custom ordering rules.
This should resolve the ORA-00933 error and execute as intended.
内容的提问来源于stack exchange,提问作者Manan Kapoor
相关产品推荐
相关产品推荐

