Прескочи към главното съдържание

AVG

в List of Functions
Списък с автори
Публикувани: 17.07.2019 г.|Последно обновено: 3.11.2022 г.

The AVG function is a MYSQL function which we can use to find the average value of a numerical field.

It can be used in a similar way to SUM.

ExampleCopy link to Example to clipboard

We have four tickets where a numerical value has been entered in custom field #1

avg5.png

To find the average value of this field we could then simply run the query below:

SELECT AVG(tickets.custom_data[1]) AS 'Average field value' FROM tickets
copy

This would output the below:

avg2.png

It's often useful to have a GROUP BY field with this data as well.

For example you could group by agent to find the average value per agent using the below:

SELECT AVG(tickets.custom_data[1]) AS 'Average field value' FROM tickets GROUP BY tickets.agent
copy

To output:

AVG3.png

The matrix function can also be used to good effect with this function.

ПолезноНе беше полезно
следваща страницаDPQL_PERCENT
предишна страницаSUM

Моля, логнете се или се регистрирайте, за да оставите коментар.