설문조사
PostgreSQL/PPAS 관련 듣고 싶은 교육은


총 게시물 94건, 최근 0 건
   

Windows Functions 지원

글쓴이 : PostgresDBA 날짜 : 2012-12-04 (화) 15:07 조회 : 4878
오라클 처럼 windows function 도 훌륭히 지원합니다.

scott@[local]:5432 scottdb#SQL> 
select e.ename, deptno,
avg(e.sal) over (partition by e.deptno),
sum(e.sal) over (partition by e.deptno),
rank() over (partition by deptno order by e.sal desc),
dense_rank() over (partition by deptno order by e.sal desc)
from emp e;
 ename  | deptno |          avg          |  sum  | rank | dense_rank 
--------+--------+-----------------------+-------+------+------------
 KING   |     10 | 2916.6666666666666667 |  8750 |    1 |          1
 CLARK  |     10 | 2916.6666666666666667 |  8750 |    2 |          2
 MILLER |     10 | 2916.6666666666666667 |  8750 |    3 |          3
 FORD   |     20 | 2175.0000000000000000 | 10875 |    1 |          1
 SCOTT  |     20 | 2175.0000000000000000 | 10875 |    1 |          1
 JONES  |     20 | 2175.0000000000000000 | 10875 |    3 |          2
 ADAMS  |     20 | 2175.0000000000000000 | 10875 |    4 |          3
 SMITH  |     20 | 2175.0000000000000000 | 10875 |    5 |          4
 BLAKE  |     30 | 1566.6666666666666667 |  9400 |    1 |          1
 ALLEN  |     30 | 1566.6666666666666667 |  9400 |    2 |          2
 TURNER |     30 | 1566.6666666666666667 |  9400 |    3 |          3
 WARD   |     30 | 1566.6666666666666667 |  9400 |    4 |          4
 MARTIN |     30 | 1566.6666666666666667 |  9400 |    4 |          4
 JAMES  |     30 | 1566.6666666666666667 |  9400 |    6 |          5
(14 rows)

Time: 1.583 ms
scott@[local]:5432 scottdb#SQL> 

오. PostgreSQL 훌륭합니다.

   

postgresdba.com