我有以下数据
11/10/2011 john Maths
12/10/2011 Max Geometry
11/10/2011 John Geometry
12/10/2011 Max Maths
所以我想要以下结果
1 11/10/2011 john Maths
2 12/10/2011 John Geometry
1 11/10/2011 Max Geometry
2 12/10/2011 John Geometry
答案 0 :(得分:1)
select
row_number() over(partition by [name] order by [date] asc, [subject] asc) as row,
[date],
[name],
[subject]
from table_name
详细了解row_number()
on MSDN。
答案 1 :(得分:0)
您应该使用的是row_number() over (partition by name, order by name)
将此子句添加到您对学生的简单查询中。