SQL 2005
select Row_number() over(order by studid) as px,studid,studname,courid,courname,yeartermid,courorder from T
SQL 2000
select a.stor_id,(select count(*) + 1 qty from sales b where a.qty > b.qty and a.stor_id = b.stor_id) from sales a order by stor_id,qty |