Try giving same
Alias Names. See this:
insert into a(aa,b,c,d)
SELECT @curRank :=IF(@prevVal= exammarks.Test1, @curRank, @studentN) AS aa,
@percentile := IF(@prevVal=exammarks.Test1 , @percentile,(@totalS - @studentN + 1)/(@totalS)*100) as b,
@studentN := @studentN + 1 as c,
@prevVal:=exammarks.Test1 as d
FROM student,exammarks, (
SELECT @curRank :=0, @prevVal:=null, @studentN:=1, @percentile:=100 ) r
WHERE student.idstudent = exammarks.stdid
ORDER BY exammarks.Test1 DESC
Hope it helps!
--Amit