Using Alias in query resulting in “command not properly ended”

前端 未结 1 697
一整个雨季
一整个雨季 2020-12-04 04:28

I tried this:

SELECT *
FROM (SELECT *
           , ROW_NUMBER() OVER (ORDER BY vernum DESC, defvern DESC) AS RowNumber
      FROM   MyTable
             INN         


        
相关标签:
1条回答
  • 2020-12-04 04:36

    Oracle does not support table alias with the as.

    For example:

    SQL> select 1
      2  from dual as a;
    from dual as a
                 *
    ERROR at line 2:
    ORA-00933: SQL command not properly ended
    
    
    SQL> select 1
      2  from dual a;
    
             1
    ----------
             1
    

    The same way:

    SQL> select *
      2  from (
      3        select 1 from dual
      4       ) as a;
         ) as a
              *
    ERROR at line 4:
    ORA-00933: SQL command not properly ended
    
    
    SQL> select *
      2  from (
      3        select 1 from dual
      4       )  a;
    
             1
    ----------
             1
    

    Column alias can be both with and without the as:

    SQL> select 1 as one, 2 two
      2  from dual;
    
           ONE        TWO
    ---------- ----------
             1          2
    
    0 讨论(0)
提交回复
热议问题