无论如何,我可以存档如下吗? 基本上它需要根据主题本身来计算。
Student Term Subject Count
------------------------------------------------------
0001 AUG2013 ABC1234 0
0001 Jan2014 ABC1234 1
0001 Jan2014 DEF1234 0
0001 May2014 ABC1234 2
0001 May2014 GHI1234 0
答案 0 :(得分:2)
试试这个
SELECT
Student,
Term,
Subject,
ROW_NUMBER() OVER (PARTITION BY Student, Subject ORDER BY Term)-1 AS Count
FROM
TableName