title: Adding total of columns when another column changes
body: <p>I am currently trying to create a java program that:</p>
  
  <ol>
  <li>Retrieves data from an Oracle sql database (String and BigDecimal values) and puts them in a resultSet</li>
  <li>Displays each row</li>
  <li>Adds a "totals" section at the end of each group, divided by 3 columns of String values.</li>
  </ol>
  
  <p>I am having trouble with No.3 - I'm not sure how to tally up the totals depending on a change in another column.</p>
  
  <p>To flesh out No.3...
  There are 7 columns, 1~3 String codes for department, store, and region IDs (String); 4 is an individual's ID (String); 5~7 the values for three different payments Salary, Overtime, and Adjusted total pay (BigDecimal).
  I need to add up and display the totals of each department, store, and region as they change (as the String value for each of them change): for example, the program would display each row of individuals in order, then display the department's totals when the department code changes. When both department and store change, both of those totals are displayed, one row after the other.</p>
  
  <p>I have thought of using a treeMap but I can't get past whether I can sort depending on another column's values; and I can't think up a way to detect the change in department, store, and region ID codes... </p>
  
  <p>It's a little over my head, I admit; and I would appreciate any help.
  Please let me know if you need more info - I feel like I've described what's needed but I might have missed something.</p>
  
  <p>Thanks in advance!</p>