Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les compléments
Voir le programme détaillé
Module « sqlalchemy »

Fonction within_group - module sqlalchemy

Signature de la fonction within_group

def within_group(element: 'FunctionElement[_T]', *order_by: '_ColumnExpressionArgument[Any]') -> 'WithinGroup[_T]' 

Description

help(sqlalchemy.within_group)

Produce a :class:`.WithinGroup` object against a function.

Used against so-called "ordered set aggregate" and "hypothetical
set aggregate" functions, including :class:`.percentile_cont`,
:class:`.rank`, :class:`.dense_rank`, etc.

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

    from sqlalchemy import within_group

    stmt = select(
        department.c.id,
        func.percentile_cont(0.5).within_group(department.c.salary.desc()),
    )

The above statement would produce SQL similar to
``SELECT department.id, percentile_cont(0.5)
WITHIN GROUP (ORDER BY department.salary DESC)``.

:param element: a :class:`.FunctionElement` construct, typically
 generated by :data:`~.expression.func`.
:param \*order_by: one or more column elements that will be used
 as the ORDER BY clause of the WITHIN GROUP construct.

.. seealso::

    :ref:`tutorial_functions_within_group` - in the
    :ref:`unified_tutorial`

    :data:`.expression.func`

    :func:`_expression.over`



Vous êtes un professionnel et vous avez besoin d'une formation ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé