I have just realized that I am processing the subset in reverse order (i.e. latest date backwards)
I want to process in earliest date forwards direction The subset should consist of 102 records I ignore the most recent I look at the earliest - and record the prediction only For the rest I record the current class and compare it with the prediction from the previous record My code is as follows:- try { rs = s.executeQuery("SELECT * FROM xxx WHERE TRADE_NO <>0 ORDER BY Trading_Date DESC," + " Trading_Time DESC FETCH NEXT 101 ROWS ONLY"); // myConsole.getOut().println("Successfully retrieved 101 records from xxx table: "); int k = 0; while (k < 100) { // for k = 0 record, just get predictions rs.next(); String Date5 = rs.getString("Trading_Date"); int Time5 = rs.getInt("Trading_Time"); if (k < 1) { pred_test1 = rs.getString("Class1_Predicted"); if (j == 0) { pred_test = pred_test1;} } if (k > 0) { // get class_current and profit from (k)th record class_current = rs.getString("class_current"); test_profit = rs.getDouble("Profit_Loss"); [some calculations............] pred_test = ""; class_current = ""; test_profit = 0; pred_test1 = rs.getString("Class1_Predicted"); if (j == 0) { pred_test = pred_test1;} } k++; } } catch (SQLException e) { myConsole.getOut().println(e); } // end of simulation - 100 simulation records ------------------------------------------------------- If you could indicate code changes to reverse the handling direction I would be delighted Thank you Bob M -- View this message in context: http://apache-database.10148.n7.nabble.com/Processing-a-subset-of-records-correctly-tp145844.html Sent from the Apache Derby Users mailing list archive at Nabble.com.