|
@@ -3378,7 +3378,7 @@ by the aggregate.
|
|
|
``Avg``
|
|
|
~~~~~~~
|
|
|
|
|
|
-.. class:: Avg(expression, output_field=None, filter=None, **extra)
|
|
|
+.. class:: Avg(expression, output_field=None, distinct=False, filter=None, **extra)
|
|
|
|
|
|
Returns the mean value of the given expression, which must be numeric
|
|
|
unless you specify a different ``output_field``.
|
|
@@ -3387,6 +3387,18 @@ by the aggregate.
|
|
|
* Return type: ``float`` if input is ``int``, otherwise same as input
|
|
|
field, or ``output_field`` if supplied
|
|
|
|
|
|
+ Has one optional argument:
|
|
|
+
|
|
|
+ .. attribute:: distinct
|
|
|
+
|
|
|
+ If ``distinct=True``, ``Avg`` returns the mean value of unique values.
|
|
|
+ This is the SQL equivalent of ``AVG(DISTINCT <field>)``. The default
|
|
|
+ value is ``False``.
|
|
|
+
|
|
|
+ .. versionchanged:: 3.0
|
|
|
+
|
|
|
+ Support for ``distinct=True`` was added.
|
|
|
+
|
|
|
``Count``
|
|
|
~~~~~~~~~
|
|
|
|
|
@@ -3451,13 +3463,25 @@ by the aggregate.
|
|
|
``Sum``
|
|
|
~~~~~~~
|
|
|
|
|
|
-.. class:: Sum(expression, output_field=None, filter=None, **extra)
|
|
|
+.. class:: Sum(expression, output_field=None, distinct=False, filter=None, **extra)
|
|
|
|
|
|
Computes the sum of all values of the given expression.
|
|
|
|
|
|
* Default alias: ``<field>__sum``
|
|
|
* Return type: same as input field, or ``output_field`` if supplied
|
|
|
|
|
|
+ Has one optional argument:
|
|
|
+
|
|
|
+ .. attribute:: distinct
|
|
|
+
|
|
|
+ If ``distinct=True``, ``Sum`` returns the sum of unique values. This is
|
|
|
+ the SQL equivalent of ``SUM(DISTINCT <field>)``. The default value is
|
|
|
+ ``False``.
|
|
|
+
|
|
|
+ .. versionchanged:: 3.0
|
|
|
+
|
|
|
+ Support for ``distinct=True`` was added.
|
|
|
+
|
|
|
``Variance``
|
|
|
~~~~~~~~~~~~
|
|
|
|