大家好,这是我的SQL语句,
SQL> select count(*) from testresult t where t.customer_id=94 and t.test_id=(select e.exam_id from exam e where e.end_time is null and rownum=1 and e.customer_id=94 order by start_time desc);总提示这个错误ERROR 位于第 1 行:
ORA-00907: 缺少右括号为什么???请大侠指教~~
SQL> select count(*) from testresult t where t.customer_id=94 and t.test_id=(select e.exam_id from exam e where e.end_time is null and rownum=1 and e.customer_id=94 order by start_time desc);总提示这个错误ERROR 位于第 1 行:
ORA-00907: 缺少右括号为什么???请大侠指教~~
解决方案 »
- oracle中哪个系统表是存储临时表的?
- 如何用触发器防止插入重复字段
- 数据库设计讨论
- 请问各位专家:Sqlldr 的ctl文件中用TAB键做分割符,怎么写?
- 详细解释一下 ODBC 或 BDE , ADO 和 OLE DB ??
- 高手: 用oracle 批量(几万条)插入数据,因为无法保证数据的可靠性,速度很慢,用commit ,速度一下就快了。有什么解决办法。
- 这段代码有错吗大家帮看看
- Pro*C 在哪里安装。
- 求助sql问题,在线等,急!!!
- plsql创建表,注释显示问号;查询时,中文可以正常显示
- 如何循环调用带返回值的存储过程。
- 求一个双表关联的update语句的简单问题,刚学oracle不久。。。。急。。多谢
或者把order by start_time desc改成order by e.start_time desc试试
select count(*) from testresult t where t.customer_id=94 and t.test_id in (select e.exam_id from exam e where e.end_time is null and rownum=1 and e.customer_id=94 order by start_time desc);
如果是单行的话就后面用select top 1 ......最好前面用in而不是等号
count(*)
from
testresult t,
(select
e.exam_id
from exam e
where
e.end_time is null
and rownum=1
and e.customer_id=94
order by start_time desc
) tmp
where
t.customer_id=94
and t.test_id= tmp.exam_id
/
SQL> / COUNT(*)
----------
0