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.
We have four tickets where a numerical value has been entered in custom field #1
To find the average value of this field we could then simply run the query below:
SELECT AVG(tickets.custom_data) AS 'Average field value' FROM tickets
This would output the below:
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) AS 'Average field value' FROM tickets GROUP BY tickets.agent
The matrix function can also be used to good effect with this function.