Last Updated: February 25, 2016
·
629
· mushfiq

Rank SQL query Result

At first declare a variable like below:

set @counter=0;

Then run query like below:

select @counter:=@counter+1 as Rank,LastName,Roll_no as Roll  from       Students order by Roll_no ASC;

My example table name is Students,ranking based on roll no.