AVG - Average in Teradata

In order to get the average value from a column in a table, AVG function can be used.

Example:
SELECT AVG(salary)
FROM tbl_employee;


Generally, AVG function will be used with GROUP BY clause to find the average value for each group.

Example:
SELECT AVG(salary), dept_id
FROM
tbl_employee
GROUP BY dept_id;


In the above example, the average salary for every dept_id will be displayed.
Please note that since AVG function can act independently, we don't need to add it in GROUP BY clause.