我写了个select * from courses union  select * from minors order by 1 在SQL/PLUS 里面运行,
可是我写了select * from courses union  select * from minors order by desc  系统却提示:ORA-00936:缺失表达式初学这个,书上没写ORDER BY ASC 与ORDER BY 1 的区别?
想请教下,

解决方案 »

  1.   

    select * from courses union  select * from minors order by 1
    对第一个字段进行升序排序select * from courses union  select * from minors order by desc  
    错误,加个表中存在(或转换过后的)的字段名(或转换过后的)
    例如
    select * from courses union  select * from minors order by id desc  select substr(id , 1 , 2) new_id, * from courses union  select * from minors order by substr(id , 1 , 2) desc  
      

  2.   

    ORDER BY 1 表示 所select 的字段按第一个字段排序
    ORDER BY ASC应该没有这样写法,ORDER BY 后面不是字段就是数字,
    可以ORDER BY 1 ASC 或者ORDER BY COL1 ASCASC表示按升序排序,DESC表示按降序排序