This function is used to return the average value.
avg(col), avg(DISTINCT col)
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
col |
Yes |
All data types |
The value can be of any data type and can be converted to the DOUBLE type for calculation. |
The return value is of the DOUBLE type.
If the value of col is NULL, the column is not involved in calculation.
select avg(items) from warehouse;
The command output is as follows:
_c0 100.0
select warehourseId, avg(items) from warehourse group by warehourseId;
The command output is as follows:
warehouseId _c1 city1 155 city2 101 city3 194