ORACLE 缺少右括号 紧急求助

zxianwu 2007-04-07 11:10:01

select S.STATION_NAME AS station_name,
(select E.ID from OM_ELEC_DETAIL E where S.ID=E.BASE_ID and rownum<2 order by E.ID desc) AS chargeId

from OM_BASE_STATION S

在ORacle 中运行 报错:缺少右括号;请高手帮我解决,本人很少写ORACLE语句。

解决为谢!!!
...全文
617 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
小李木耳 2007-04-10
  • 打赏
  • 举报
回复
我不是要分的,很少像楼主这样写sql:
-----------------------

Select S.STATION_NAME AS station_name,
( Select E.ID from OM_ELEC_DETAIL E
where S.ID=E.BASE_ID and rownum<2 ) AS chargeId,
( Select E.ADDR from OM_ELEC_DETAIL E
where S.ID=E.BASE_ID and rownum<2 ) AS addr,
from OM_BASE_STATION S order by chargeId,addr desc
-----------------------
你的那种方法可以,但是我还要加多个字段就不可行?

我调试了一下这样的sql:
select s.xh,
s.xm,
(select t1.ski_niuke_cd
from abc121313_0 t1
where S.xh = t1.ski_niuke_cd
and rownum < 2) as dd,
(select t2.ord
from abc121313_0 t2
where S.xh = t2.ski_niuke_cd
and rownum < 2) as ddd,
s.num
from aa_test s
order by dd, ddd desc
可以执行的,你把错误提示写出来!
zxianwu 2007-04-07
  • 打赏
  • 举报
回复
Select S.STATION_NAME AS station_name,
( Select E.ID from OM_ELEC_DETAIL E
where S.ID=E.BASE_ID and rownum<2 ) AS chargeId,
( Select E.ADDR from OM_ELEC_DETAIL E
where S.ID=E.BASE_ID and rownum<2 ) AS addr,
from OM_BASE_STATION S order by chargeId,addr desc

大哥你的那种方法可以,但是我还要加多个字段就不可行,帮帮忙,搞定给你100分,我在等待你的回复。
jinanjiang 2007-04-07
  • 打赏
  • 举报
回复
study
WangZWang 2007-04-07
  • 打赏
  • 举报
回复
--改为
Select S.STATION_NAME AS station_name,
( Select E.ID from OM_ELEC_DETAIL E
where S.ID=E.BASE_ID and rownum<2 ) AS chargeId
from OM_BASE_STATION S order by chargeId.ID desc
zxianwu 2007-04-07
  • 打赏
  • 举报
回复
因为我是的项目中需要排序,麻烦您帮我看看,出不来我项目都没法进展。
zxianwu 2007-04-07
  • 打赏
  • 举报
回复
那样的话是可以的,但我需要排序。
CathySun118 2007-04-07
  • 打赏
  • 举报
回复
子句的order by没有用去掉,改为:
select S.STATION_NAME AS station_name,
(select E.ID from OM_ELEC_DETAIL E where S.ID=E.BASE_ID and rownum=1 ) AS chargeId
from OM_BASE_STATION S 试试

17,140

社区成员

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

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