一个非常奇怪的问题

Corn1 2014-09-15 04:24:12
表结构:
create table T_O_TopNDisconnect
(
ID number(10) not null,
EventID number(10) null,
JobDetailID number(10) default 13201 not null,
MissionID number(10) null,
ZoneID number(10) null,
TimeStamp date not null,
SectorName varchar2(100) not null,
SectorOID varchar2(50) not null,
BoardCount number(10) not null,
BusiDiscRate number(10,4) not null,
BusiDiscCount number(10) not null,
CallSuccCount number(10) not null,
BecallSuccCount number(10) not null,
DiscInterval number(10,4) not null,
BussCallCount number(10,4) not null,
CurrDate date null,
ColorID number(1) default 0 not null,
CheckBoardCount number(10) default 0 not null,
DealDate date null,
DealValue number(10,4) null,
DealProgressID number(1) default 1 not null,
OperatorID number(10) null,
Analyze varchar2(500) null,
AuditResult number(1) default 0 not null,
AuditTime date null,
AuditOperatorID number(10) null,
AuditRemark varchar2(500) null
)
tablespace NOMSSPACE;

我现在需要更新CheckBoardCount字段,值为该SectorOID的过去6天内(包括当天),BusiDiscRate>2.5的天数。
同样的一段话:
update T_O_TopNDisconnect a set CheckBoardCount=(select count(*) from (select distinct CurrDate from T_O_TopNDisconnect b where (b.CurrDate between a.CurrDate-6 and a.CurrDate) and (b.BusiDiscRate>2.5) and (b.SectorOID=a.SectorOID)))
where exists (select 1 from T_O_TopNDisconnect b where (b.CurrDate between a.CurrDate-6 and a.CurrDate) and (b.BusiDiscRate>2.5) and (b.SectorOID=a.SectorOID) and a.AuditResult=0);
在oracle10g中执行成功,但11g,报错:
ORA-00904: "A"."SECTOROID": 标识符无效

请问是什么原因?
...全文
149 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
bw555 2014-09-15
  • 打赏
  • 举报
回复
update T_O_TopNDisconnect a
set CheckBoardCount=(select count(distinct CurrDate) from T_O_TopNDisconnect b
    where (b.CurrDate between a.CurrDate-6 and a.CurrDate) and (b.BusiDiscRate>2.5) and (b.SectorOID=a.SectorOID))
where exists (select 1 from T_O_TopNDisconnect b
    where (b.CurrDate between a.CurrDate-6 and a.CurrDate) and (b.BusiDiscRate>2.5) and (b.SectorOID=a.SectorOID) and a.AuditResult=0);
子查询层级太多了,最里面已经不能访问最外层的表名了吧 可以用count(distinct CurrDate)去掉一层子查询

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧