日期:2014-05-17  浏览次数:20668 次

新手写oracle语句,求指导。
select * from v_inp_orders where 
  orderdept!=6 and prestatus not in (8) and isdelete='0'
  and direcode in('03','25','59','92','114','119','115','116','117','46','02','04','06','11','37','51','10','47',
  '62','63','64','65','66','67','104','80','81','107','121')  
  order by reg_no,pre_no,groupno 
   
union all
 
select * from v_inp_orders_all where 
  orderdept!=6 and prestatus not in (8) and isdelete='0'
  and itemcode in('SF0083','SF7970','SF9141','SF0068','SF0095','SF0076','SF0130','SF0067','SF9117',
  'SF6812','SF0065','SF0064','SF0116','SF0117','SF0115','SF0131','SF0069','SF0573',
  'SF0655','SF0114','SF0124','SF6987','SF6996') 
  order by reg_no,pre_no,groupno



就是这个语句,提示语句未正确结束,然后我把上面的order by注释掉之后提示无效标识符,希望各位高手指导一下。

------解决方案--------------------
1. union all 不能加 order by 
2. union all 中,select 字段必须相同,上面有几个字段,下面也要几个字段,顺序要相同
------解决方案--------------------
探讨
1. union all 不能加 order by
2. union all 中,select 字段必须相同,上面有几个字段,下面也要几个字段,顺序要相同