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.
Example
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[1]) AS 'Average field value'
FROM tickets copy
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[1]) AS 'Average field value'
FROM tickets
GROUP BY tickets.agent copy
To output:
The matrix function can also be used to good effect with this function.
Please log in or register to submit a comment.