how to get rank of student on the basis of his total marks by using rownum function in JSP? below is my code

 try
    {
    Connection con=dbConnect.getConnect();
    Statement st=con.createStatement();
    String department = request.getParameter("department");

    ResultSet rs=st.executeQuery("SELECT  rank,id,sname,firstsem,secondsem,thirdsem,fourthsem,fifthsem,sixthsem, sum(firstsem+secondsem+thirdsem+fourthsem+fifthsem+sixthsem) as total from pg where department='" + department + "' group by id order by total DESC ");%>

    <table cellpadding="10" border="2" >

     <tr><td><b>RANK</b></td> <tr><td><b>STUDENT ID</b></td><td><b>STUDENT NAME</b></td><td><b>1St Sem</b></td><td><b>2Nd Sem</b></td><td><b>3Rd Sem</b></td><td><b>4Th Sem</b></td><td><b>5Th Sem</b></td><td><b>6Th Sem</b></td><td><b>Total</b></td></tr>
       <% while(rs.next())
       {%>
     <td><tr><td><%=rs.getString(1)%></td><td><%=rs.getString(2)%></td><td><%=rs.getString(3)%></td><td><%=rs.getString(4)%></td><td><%=rs.getString(5)%></td><td><%=rs.getString(6)%></td><td><%=rs.getString(7)%></td><td><%=rs.getString(8)%></td><td><%=rs.getString(9)%>       
        <%} %>
    </table>

    <%}


Source: jsp

Leave a Reply