windows aggregate functions in postgresql

Solutions on MaxInterview for windows aggregate functions in postgresql by the best coders in the world

showing results for - "windows aggregate functions in postgresql"
Yann
30 Nov 2019
1SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM empsalary;
2
Abby
11 Jan 2017
1  depname  | empno | salary |          avg          
2-----------+-------+--------+-----------------------
3 develop   |    11 |   5200 | 5020.0000000000000000
4 develop   |     7 |   4200 | 5020.0000000000000000
5 develop   |     9 |   4500 | 5020.0000000000000000
6 develop   |     8 |   6000 | 5020.0000000000000000
7 develop   |    10 |   5200 | 5020.0000000000000000
8 personnel |     5 |   3500 | 3700.0000000000000000
9 personnel |     2 |   3900 | 3700.0000000000000000
10 sales     |     3 |   4800 | 4866.6666666666666667
11 sales     |     1 |   5000 | 4866.6666666666666667
12 sales     |     4 |   4800 | 4866.6666666666666667
13(10 rows)
14