select distinct(SUBSTR(trait_value,1,6)) from zzb2 where SUBSTR(trait_value,1,4)= '2009' order by trait_value asc
运行上面sql报:不是selected表达式
用oracle怎么写??

解决方案 »

  1.   

    order by trait_value asc改成order by 1 asc因为trait_value没有出现在select部分,所以报错
      

  2.   

    ORA-01791: not a SELECTed expression 
    ------------------------------------
    Cause: There is an incorrect ORDER BY item. The query is a SELECT DISTINCT query with an ORDER BY clause. In this context, all ORDER BY items must be constants, SELECT list expressions, or expressions whose operands are constants or SELECT list expressions. 
    ------------------------------------
    Action: Remove the inappropriate ORDER BY item from the SELECT list and retry the statement.  
      

  3.   

    select distinct(SUBSTR(trait_value,1,6)) from zzb2 where SUBSTR(trait_value,1,4)= '2009' order by SUBSTR(trait_value,1,6) asc