永发信息网

执行sql报错: 坐等答案 为什么不能执行,会报错:ora-00933

答案:3  悬赏:70  手机版
解决时间 2021-03-20 05:57
  • 提问者网友:沉默菋噵
  • 2021-03-19 13:12
ora-0093select 'zy',t.prjcode as 项目代号,t.prjname as 项目名称,count(t.prjcode) as 归档案卷数 from d_prj4_0028 t,d_vol4_0028 a where t.syscode=a.psyscode and t.prjcode is not null and a.attr=1 and a.attrex=3 and t.status=0 and a.gdrq like '2013%' group by t.prjcode,t.prjname having(count(t.prjcode))>=0 order by t.prjcode
union all
select 'dy',t.prjcode as 项目代号,t.prjname as 项目名称,count(t.prjcode) as 归档案卷数 from d_prj4_0005 t,d_vol4_0005 a where t.syscode=a.psyscode and t.prjcode is not null and a.attr=1 and a.attrex=3 and t.status=0 and a.gdrq like '2013%' group by t.prjcode,t.prjname having(count(t.prjcode))>=0 order by t.prjcode
最佳答案
  • 五星知识达人网友:慢性怪人
  • 2021-03-19 14:17
就看出一点毛病,就是union 前那句不要order by ,同样后一句也把order by 去掉

如果你两句单独运行没问题的话,排序可以这样
select t.* from
(查询一
union all
查询二) as t
order by 某字段

还有你zy和dy应该给这列起个别名
全部回答
  • 1楼网友:刀戟声无边
  • 2021-03-19 14:49
sql ="select stu_number, uppaper_name from (select a.*, rownum rn from (select * from xwgl_lwpsb) a where rownum <= "+end+") where rn >= "+start; 以上。
  • 2楼网友:十鸦
  • 2021-03-19 14:33
一般在oracle中报错为ora-00933是因为sql命令没有正确结束导致的,有这个语法错误就不能执行,需要检查sql语法解决。 1、比如有以下sql报错: UPDATe PEOPLE SET PEOPLE.SURNAME = HR_DATA_IMPORT.SURNAME INNER JOIN PEOPLE ON HR_DATA_IMPORT.NI.NO = PEOPLE.NI_NUMBER; 2、以上sql执行会报错ora-00933,是因为暗含了一个子查询,set值的时候需要用子查询的结果: 正确的修改如下: UPDATE PEOPLE a SET a.SURNAME = ( select b.SURNAME from PEOPLE b where b.NI.NO = a.NI_NUMBER )
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯