COUNT with GROUP BY in Teradata

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

Example:
SELECT COUNT(emp_id)
FROM tbl_employee;


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

Example:
SELECT COUNT(emp_id), dept_id
FROM
tbl_employee
GROUP BY dept_id;


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