# sqlalchemy 2.1.9 (MIT), harvested by tools/harvest_corpus.py
=== input
Produce a :class:`.AggregateOrderBy` object against a function.

    Used for aggregating functions such as :class:`_functions.array_agg`,
    ``group_concat``, ``json_agg`` on backends that support ordering via an
    embedded ``ORDER BY`` parameter, e.g. PostgreSQL, MySQL/MariaDB, SQLite.
    When used on backends like Oracle and SQL Server, SQL compilation uses that
    of :class:`.WithinGroup`.  On PostgreSQL, compilation is fixed at embedded
    ``ORDER BY``; for set aggregation functions where PostgreSQL requires the
    use of ``WITHIN GROUP``, :func:`_expression.within_group` should be used
    explicitly.

    :func:`_expression.aggregate_order_by` is usually called using
    the :meth:`.FunctionElement.aggregate_order_by` method, e.g.::

        stmt = select(
            func.array_agg(department.c.code).aggregate_order_by(
                department.c.code.desc()
            ),
        )

    which would produce an expression resembling:

    .. sourcecode:: sql

        SELECT array_agg(department.code ORDER BY department.code DESC)
        AS array_agg_1 FROM department

    The ORDER BY argument may also be multiple terms.

    When using the backend-agnostic :class:`_functions.aggregate_strings`
    string aggregation function, use the
    :paramref:`_functions.aggregate_strings.order_by` parameter to indicate a
    dialect-agnostic ORDER BY expression.

    .. versionadded:: 2.1 Generalized the PostgreSQL-specific
       :func:`_postgresql.aggregate_order_by` function to a method on
       :class:`.Function` that is backend agnostic.

    .. seealso::

        :class:`_functions.aggregate_strings` - backend-agnostic string
        concatenation function which also supports ORDER BY

    
=== parse rest
short_description: 'Produce a :class:`.AggregateOrderBy` object against a function.'
long_description: |
  Used for aggregating functions such as :class:`_functions.array_agg`,
  ``group_concat``, ``json_agg`` on backends that support ordering via an
  embedded ``ORDER BY`` parameter, e.g. PostgreSQL, MySQL/MariaDB, SQLite.
  When used on backends like Oracle and SQL Server, SQL compilation uses that
  of :class:`.WithinGroup`.  On PostgreSQL, compilation is fixed at embedded
  ``ORDER BY``; for set aggregation functions where PostgreSQL requires the
  use of ``WITHIN GROUP``, :func:`_expression.within_group` should be used
  explicitly.
  
  :func:`_expression.aggregate_order_by` is usually called using
  the :meth:`.FunctionElement.aggregate_order_by` method, e.g.::
  
      stmt = select(
          func.array_agg(department.c.code).aggregate_order_by(
              department.c.code.desc()
          ),
      )
  
  which would produce an expression resembling:
  
  .. sourcecode:: sql
  
      SELECT array_agg(department.code ORDER BY department.code DESC)
      AS array_agg_1 FROM department
  
  The ORDER BY argument may also be multiple terms.
  
  When using the backend-agnostic :class:`_functions.aggregate_strings`
  string aggregation function, use the
  :paramref:`_functions.aggregate_strings.order_by` parameter to indicate a
  dialect-agnostic ORDER BY expression.
  
  .. versionadded:: 2.1 Generalized the PostgreSQL-specific
     :func:`_postgresql.aggregate_order_by` function to a method on
     :class:`.Function` that is backend agnostic.
  
  .. seealso::
  
      :class:`_functions.aggregate_strings` - backend-agnostic string
      concatenation function which also supports ORDER BY
blank_after_short_description: True
blank_after_long_description: False
style: rest
=== detect
rest
=== compose rest
Produce a :class:`.AggregateOrderBy` object against a function.

Used for aggregating functions such as :class:`_functions.array_agg`,
``group_concat``, ``json_agg`` on backends that support ordering via an
embedded ``ORDER BY`` parameter, e.g. PostgreSQL, MySQL/MariaDB, SQLite.
When used on backends like Oracle and SQL Server, SQL compilation uses that
of :class:`.WithinGroup`.  On PostgreSQL, compilation is fixed at embedded
``ORDER BY``; for set aggregation functions where PostgreSQL requires the
use of ``WITHIN GROUP``, :func:`_expression.within_group` should be used
explicitly.

:func:`_expression.aggregate_order_by` is usually called using
the :meth:`.FunctionElement.aggregate_order_by` method, e.g.::

    stmt = select(
        func.array_agg(department.c.code).aggregate_order_by(
            department.c.code.desc()
        ),
    )

which would produce an expression resembling:

.. sourcecode:: sql

    SELECT array_agg(department.code ORDER BY department.code DESC)
    AS array_agg_1 FROM department

The ORDER BY argument may also be multiple terms.

When using the backend-agnostic :class:`_functions.aggregate_strings`
string aggregation function, use the
:paramref:`_functions.aggregate_strings.order_by` parameter to indicate a
dialect-agnostic ORDER BY expression.

.. versionadded:: 2.1 Generalized the PostgreSQL-specific
   :func:`_postgresql.aggregate_order_by` function to a method on
   :class:`.Function` that is backend agnostic.

.. seealso::

    :class:`_functions.aggregate_strings` - backend-agnostic string
    concatenation function which also supports ORDER BY
