Skip to content

Clarify min, max and rank documentation #8760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/codeql/ql-language-reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ The following aggregates are available in QL:

- ``min`` and ``max``: These aggregates determine the smallest (``min``) or largest (``max``)
value of ``<expression>`` among the possible assignments to the aggregation variables.
In this case, ``<expression>`` must be of numeric type or of type ``string``.

``<expression>`` must be of numeric type or of type ``string``, or an explicit order must be defined with ``order by``.
When using ``order by``, more than one result may exist in case of ties.

For example, the following aggregation returns the name of the ``.js`` file (or files) with the
largest number of lines, using the number of lines of code to break ties:

Expand Down Expand Up @@ -297,9 +298,10 @@ The following aggregates are available in QL:
.. index:: rank

- ``rank``: This aggregate takes the possible values of ``<expression>`` and ranks them.
In this case, ``<expression>`` must be of numeric type or of type ``string``. The aggregation
returns the value that is ranked in the position specified by the **rank expression**.
``<expression>`` must be of numeric type or of type ``string``, or an explicit order must be defined with ``order by``.
The aggregation returns the value that is ranked in the position specified by the **rank expression**.
You must include this rank expression in brackets after the keyword ``rank``.
When using ``order by``, more than one result may exist in case of ties.

For example, the following aggregation returns the value that is ranked 4th out of all the
possible values. In this case, ``8`` is the 4th integer in the range from ``5`` through
Expand Down