Computing an Average

Find the average salary for all employee as well as the average salary for each department

select avg(sal) as avg_sal
from emp

select avg(sal) as avg_sal
from emp
group by deptno

group by automatically cause aggregate function such as AVG to execute and return a result for each group

If you want to find the max or min of the group, sub avg to min and max function.

Do you want to count how many rows, use function count (*) or if you want to know how many in depno 10 or depno 20?

select depno, count (*)
from emp
group by depno

When you use count(*), you are counting the whole rows, but when you COUNTa column, you are counting the non-NULL value in that column.

I would add some later, now I need to focus on understanding not my note.