DEPTNO ENAME
---------- ----------
A ASMITH
A BALLEN
A CWARD
B DJONES
B EMARTIN
C FBLAKE
C GCLARK
C HSCOTT
↓↓↓↓ 想要分組有編號
DEPTNO ENAME SEQ
---------- ------ ----
A ASMITH 1
A BALLEN 2
A CWARD 3
B DJONES 1
B EMARTIN 2
C FBLAKE 1
C GCLARK 2
C HSCOTT 3
SELECT DEPTNO, ENAME,row_number() over(partition by DEPTNO ORDER BY ENAME)SEQ FROM XXX
partition by DEPTNO←←依DEPTNO分組
如果沒要分組可省略partition by
沒有留言:
張貼留言