You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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_test with a simple, valid alias lt. This removes the parsing confusion between the actual table name and the subquery alias.
  • Kept all your original sorting logic and rownum = 1 filter 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:58:27