ho questo codice fatto un po' alla carlona, ma non so come trovare il numero delle righe trovate, mi serve sapere perchè non mi esegue la seconda query:spero sia chiarocodice:ResultSet rs_risorse=sql.executeQuery("SELECT consuntivo.id_risorsa, risorse.nome_risorsa FROM consuntivo LEFT JOIN risorse on risorse.id_risorsa=consuntivo.id_risorsa GROUP BY id_risorsa"); // Move to the end of the result set rs_risorse.last(); // Get the row number of the last row which is also the row count int trovati = rs_risorse.getRow(); out.println("righe"+trovati); rs_risorse.beforeFirst(); for (int a=0;a<trovati;a++) { rs_risorse.next(); int id_risorsa=rs_risorse.getInt("id_risorsa"); nome_risorsa=rs_risorse.getString("nome_risorsa"); riga_settimana=riga_settimana+"<th>"+nome_risorsa+"</th>"; //DEBUG out.println("id_risorsa="+id_risorsa); out.println(" "+nome_risorsa+" "); for(int i=1;i<53;i++) { query_consuntivo="SELECT * FROM consuntivo WHERE id_commessa='1' AND id_risorsa="+id_risorsa+" AND settimana_consuntivo="+i; //debug //out.println(" "+query_consuntivo); if (i==52) riga_tabella=riga_tabella+"<td>"+i+"</td><td>Totali</td></tr>"; else riga_tabella=riga_tabella+"<td>"+i+"</td>"; ResultSet rs_consuntivo=sql.executeQuery(query_consuntivo); while(rs_consuntivo.next()) { giorni_consuntivo=rs_consuntivo.getInt("giorni_consuntivo"); //if (i==1) riga_consuntivo=riga_consuntivo+"<tr>"; riga_consuntivo=riga_tabella+"<td>"+giorni_consuntivo+"</td>"; } } }