Funciones agregadas de Windows en PostgreSQL
SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM empsalary;
Thoughtful Tamarin
SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM empsalary;