Skip to main content

AVG

in List of Functions
Authors list
Published: Jul 17, 2019|Last updated: Nov 3, 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.

HelpfulUnhelpful
next pageDPQL_PERCENT
previous pageSUM

Please log in or register to submit a comment.