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

While loop...  RSS feed

 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a bean that runs sql for me and I display on a jsp with a while loop in a table. The data consists of several rows, the first row being an SBU - Strategic Business Unit with the values od A, B, C, D, E. I need to subtotal on each value, create a line, and start with the next SBU. How can do this. The following is an example of what I would like:
A 1
A 4
Sub 5
B 3
B 4
B 1
Sub 8
etc...
Here is a snippet of my code:
...
while (rc.next()) {
%>
<tr>
<td>data</td>
<td>data</td>
etc...
<subtotal at end of each SBU>
</tr>
<% } %>
 
Debashish Chakrabarty
Ranch Hand
Posts: 231
Firefox Browser Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMHO this is more controllable through your SQL statement processed by the bean.
You may use "order by SBU", that way the totals can be done on your JSPs itself. If you wish to have pre-calculated "total" delivered to the JSP by the bean, use a "group by SBU" instead.
[ May 16, 2003: Message edited by: Debashish Chakrabarty ]
 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! The grouping functions and totals are being done in the sql. I am not sure how to break the sequence in thw while statement to insert the totals in the jsp.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!