sql server - Incremental count based on criteria -
sql server - Incremental count based on criteria -
is there anyway can archive following? need count based on subject itself.
student     term        subject     count ------------------------------------------------------ 0001        aug2013     abc1234     0 0001        jan2014     abc1234     1 0001        jan2014     def1234     0 0001        may2014     abc1234     2 0001        may2014     ghi1234     0       
try this
select    student,    term,    subject,    row_number() on (partition student, subject order term)-1 count     tablename        sql-server sql-server-2008 
 
Comments
Post a Comment