Order by n...是什么意思?

For Example:

SQL>   select   *   from   test_tab   order   by   1;  
   
  COL_A                       COL_B  
  ----------                ----------  
  A                              1  
  A                              2  
  B                              2  
  B                              3  
  C                              4  
  D                              1  
  D                              12  
  D                              121  
  D                              12  
   

  9   rows   selected  

===============================================

  SQL>   select   *   from   test_tab   order   by   2;  

  COL_A                       COL_B  
  ----------                 ----------  
  A                              1  
  D                              1  
  A                              2  
  B                              2  
  B                              3  
  C                              4  
  D                              12  
  D                              12  
  D                              121  
   

  9   rows   selected  

===============================================
  SQL>   select   *   from   test_tab   order   by   3;  
   
  select   *   from   test_tab   order   by   3  
   

  ORA-01785:   ORDER   BY   项必须是   SELECT-list   表达式的数目  

===============================================
   
   
  以上看来:1表示第一个栏位, 2表示第二栏位, 依此类推  
  当表中只有2个栏位时, ORDER  BY  3 就会出错.


你可能感兴趣的:(oracle,sql,数据库,by,order)