ORACLE/SQL: wm_concat & order by

前端 未结 6 939
梦如初夏
梦如初夏 2020-12-19 18:17

I\'m using oracle 11 (not sure about the exact version, but since LISTAGG doesn\'t work, I suppose it\'s not release 2) through ODBC and crystal reports 2008.

Here

6条回答
  •  被撕碎了的回忆
    2020-12-19 18:53

    1. Order by the desired column, then
    2. Order in external query order by row number.
    3. Use the function.

    This function has logic for the last rownum order:

    Select wmsys.wm_concat(t) CONCAT from 
    (
        Select t from (
            Select t from (
                Select 'aa' t from dual
                union
                Select 'zz' t from dual
                union
                Select 'pp' t from dual
                union
                Select 'll' t from dual
                union
                Select 'mm' t from dual
                union
                Select 'xx' t from dual
                union
                Select 'cc' t from dual
            ) a 
            order by t
        ) order by rownum
    ) t
    

提交回复
热议问题