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语句。
解决为谢!!!
...全文
6177打赏收藏
ORACLE 缺少右括号 紧急求助
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语句。 解决为谢!!!
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
可以执行的,你把错误提示写出来!
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
--改为
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
子句的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 试试