Oracle “Partition By” Keyword

前端 未结 6 874
不思量自难忘°
不思量自难忘° 2020-11-29 14:22

Can someone please explain what the partition by keyword does and give a simple example of it in action, as well as why one would want to use it? I have a SQL

6条回答
  •  有刺的猬
    2020-11-29 15:01

    EMPNO     DEPTNO DEPT_COUNT
    

     7839         10          4
     5555         10          4
     7934         10          4
     7782         10          4 --- 4 records in table for dept 10
     7902         20          4
     7566         20          4
     7876         20          4
     7369         20          4 --- 4 records in table for dept 20
     7900         30          6
     7844         30          6
     7654         30          6
     7521         30          6
     7499         30          6
     7698         30          6 --- 6 records in table for dept 30
    

    Here we are getting count for respective deptno. As for deptno 10 we have 4 records in table emp similar results for deptno 20 and 30 also.

提交回复
热议问题