我的表格是这样的
StudentId | dateenroll | 23 | 03/01 |
---|---|
23 | 05/01 |
23 | 07/05 |
23 | 08/11 |
23 | 03/01 |
与其说是row_number()
,不如说是dense_rank()
Select StudentId = concat(StudentId,'-',dense_rank() over (partition by StudentId order by dateEnrolled) )
,dateEnrolled
from YourTable
结果
StudentId dateEnrolled
23-1 03/01
23-2 05/01
23-3 07/05
23-4 08/11
23-1 03/01