I've got a question related to Java coding. I'm quite new to coding, it only has been 3 classes i've had up to now and no lie, I find it quite hard. For one of my code, I'm supposed to get this result:

My current code gives me this:

I'm missing the part where each date can have more than a single Customer_ID + quantity. I was wondering how to execute that in Java coding?
To give you an idea, here's a part of my coding (in which I believe something is missing).
Code
query = "SELECT"
+ " SALES_ORDER_DATE,"
+ " OUTPUT_DESCRIPTION,"
+ " CUSTOMER_ID,"
+ " SUM(QUANTITY) AS QUANTITY"
+ " FROM SALES_ORDER"
+ " INNER JOIN SALES_ORDER_LINE_ITEM"
+ " ON SALES_ORDER.SALES_ORDER_ID = SALES_ORDER_LINE_ITEM.SALES_ORDER_ID"
+ " INNER JOIN BOM"
+ " ON SALES_ORDER_LINE_ITEM.PRODUCT_ID = BOM.OUTPUT_PRODUCT_ID"
+ " AND SALES_ORDER.SALES_ORDER_DATE = BOM.EFFECTIVE_DATE"
+ " GROUP BY"
+ " SALES_ORDER_DATE,"
+ " OUTPUT_DESCRIPTION,"
+ " CUSTOMER_ID"
+ " ORDER BY SALES_ORDER_DATE";
result = stmt.executeQuery(query);
int dateIndex = 0;
Hashtable<String, Integer> quantities = new Hashtable<String, Integer>();
while (result.next() && dateIndex < dates.size()) {
String date = result.getString("SALES_ORDER_DATE");
String client = result.getString("CUSTOMER_ID");
while (dates.elementAt(dateIndex).compareTo(date) < 0) {
out.print("<tr><td>" + dates.elementAt(dateIndex) + "</td>");
for (String iÉtiquette : étiquettes) {
out.print("<td align='right'>");
if (quantities.get(iÉtiquette) != null) {
out.print(client + " : " + quantities.get(iÉtiquette));
quantities.remove(iÉtiquette);
} else {
out.print(" ");
}
out.print("</td>");
}
out.print("</tr>");
dateIndex++;
}
String produit = result.getString("OUTPUT_DESCRIPTION");
int quantity = result.getInt("QUANTITY");
quantities.put(produit, quantity);
}
while (dateIndex < dates.size() && quantities.size() != 0) {
out.print("<tr><td>" + dates.elementAt(dateIndex) + "</td>");
for (String iÉtiquette : étiquettes) {
out.print("<td align='right'>");
if (quantities.get(iÉtiquette) != null) {
out.print(quantities.get(iÉtiquette));
quantities.remove(iÉtiquette);
} else {
out.print(" ");
}
out.print("</td>");
}
out.print("</tr>");
dateIndex++;
}