再说明一下id是number型,carpath是varchar2型

解决方案 »

  1.   

    select carpath ||','||to_char(id) as path
    from a
    order by carpath ||','||to_char(id) desc
      

  2.   

    同意楼上,concat只能是两个字符相连,如果多余两个,要么使用多个concat,要么就要使用||来连接
    楼主的语句中concat连接三个字符,这样就会报错
    如果要使用concat,你可以这样:
    select concat(concat(catpath,','),id) as path from A order by path desc;
    至于id,你可以不用做to_char的处理,这里直接就转换了关于concat的详细解释见下面:
    CONCAT returns char1 concatenated with char2. Both char1 and char2 can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The string returned is in the same character set as char1. Its datatype depends on the datatypes of the arguments.In concatenations of two different datatypes, Oracle returns the datatype that results in a lossless conversion. Therefore, if one of the arguments is a LOB, then the returned value is a LOB. If one of the arguments is a national datatype, then the returned value is a national datatype. For example:CONCAT(CLOB, NCLOB) returns NCLOB 
    CONCAT(NCLOB, NCHAR) returns NCLOB 
    CONCAT(NCLOB, CHAR) returns NCLOB 
    CONCAT(NCHAR, CLOB) returns NCLOB