We apply the ROUND() function to the result of AVG() to keep the result more readable. The rest of the statement is quite the same as the previous example.
To add a diversion, we show the result in ascending order, and we put the ASC modified esplicitely in the ORDER BY clause, even though that is not necessary, since ASC is the default:
select department_id, round(avg(salary))
from employees
group by department_id
order by avg(salary) asc;
If you want a fun introduction to SQL, consider reading Head First SQL.
No comments:
Post a Comment