为什么distinct去重不起效果?

为什么select distinct deptno,last_value(sal) over(order by sal) from emp中distinct去重deptno不起效果?详情如下:

bank=# select distinct deptno,last_value(sal) over(order by deptno) from emp;
 deptno | last_value 
--------+------------
     30 |    3000.00
      0 |    5000.00
     20 |    2975.00
(3 rows)

bank=# select distinct deptno,last_value(sal) over(order by sal) from emp;
 deptno | last_value 
--------+------------
     30 |    3000.00
     20 |    1600.00
      0 |    5000.00
     30 |    1600.00
     20 |    2975.00
     20 |     800.00
(6 rows)

bank=# select * from emp;
 empno | ename |   sal   | deptno 
-------+-------+---------+--------
     3 | feng  | 2975.00 |     20
     4 | liu   | 3000.00 |     30
     1 | wang  |  800.00 |     20
     2 | ren   | 1600.00 |     30
     5 | yuan  | 5000.00 |      0
     6 | mu    | 1600.00 |     20
(6 rows)

distinct 是对整行数据去重 英文你后面的last_value 不一样 所以去重不了