Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sum of the column  RSS feed

 
Sri Gnana
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to generate the daily report , its contains fees column, here i'm getting all the fees using the while, but i'm unable to get the SUM of that column, is there any method in JSP to get the SUM.
 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try the following

int fees = 0;
int total_fees =0;
while(rs.next())
{
fees = rs.getInt("fees");
total_fees = total_fees + fees;
}

out.println("The Total fees is " + total_fees);
 
Sri Gnana
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rekha
Its working fine , Thank you
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!