【问题标题】:Oracle error while executing query : ORA-00905: Missing keyword执行查询时出现 Oracle 错误:ORA-00905:缺少关键字
【发布时间】:2021-05-26 11:26:41
【问题描述】:

在执行以下代码时:

select distinct tam.sol_id||'|'||(select sol.sol_desc from sol where sol.sol_id=tam.sol_id)||'|'||count(*)||'|'||sum(org_tran_amt)
||'|'||count(case when ott.tran_date between '01-02-2021' and '24-02-2021' as 1 else 0 end) a
from ott,tam
where tam.acid=ott.acid
and tam.gl_sub_head_code in ('85300','85320','85330','85340','85350','85360','85365','85370','85380','85390','85395')
and tran_date <= '24-02-2021'
and tam.sol_id in (select sst.sol_id from sst where sst.set_id='ROFPZ')
and not exists (select * from tct where tct.tran_date=ott.tran_date and trim(tct.tran_id)=trim(ott.tran_id)
and nvl(ott.org_tran_amt-tct.AMT_OFFSET,0)='0' and tct.entity_cre_flg='Y' and tct.del_flg='N');

收到以下错误消息作为输出:

from ott,tam
           *
ERROR at line 3:
ORA-00905: missing keyword

【问题讨论】:

  • 错误信息与您的查询不匹配(tam vs gam)。
  • JOINJOINJOIN。不要在FROM 子句中使用逗号。

标签: sql oracle ora-00905


【解决方案1】:

尝试修改语句中的case部分:

case when ott.tran_date between '01-02-2021' and '24-02-2021' then 1 else 0 end

你必须写“then”而不是“as”。

【讨论】:

  • 谢谢,但输出不理想 855|JAL|3|4500|3 843|KOT|4|3400|4 最后一列必须为 0 或小于其他值,但输出相同跨度>
  • 尝试使用 sum 而不是 count。
猜你喜欢
  • 2010-09-23
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-02
  • 2019-01-18
  • 2016-03-12
相关资源
最近更新 更多