What does LISTAGG with ORDER BY NULL actually use as the order criteria?

前端 未结 1 410
醉梦人生
醉梦人生 2020-12-15 08:58

If I do

SELECT LISTAGG( COLUMN_VALUE ) WITHIN GROUP ( ORDER BY NULL )   AS OrderByNULL,
       LISTAGG( COLUMN_VALUE ) WITHIN GROUP ( ORDER BY 1 )      AS Or         


        
相关标签:
1条回答
  • 2020-12-15 09:15

    Possibly the order will depend on many factor, including the execution plan of the query, the configuration of your instance, the version of the database, if you are on exadata or not.

    If you are not giving oracle any specific criteria to order the data you can't count on any specific ordering, even if from your trials you seem to get the data consistently sorted in a specific way.

    According to Oracle documentation for listagg:

    • The order_by_clause determines the order in which the concatenated values are returned. The function is deterministic only if the ORDER BY column list achieved unique ordering.
    0 讨论(0)
提交回复
热议问题