和查詢的情況下,我使用下面的查詢爲:如何使用NetBeans中
String qry1 = "SELECT SUM(*) FROM class_cse where Student_ID='" + StudentUserBean.getUserId() + "'";
try {
ResultSet rs, rs1;
rs = db2.stmt.executeQuery(qry1);
while (rs.next()) {
String count = rs.getString("SUM(*)");
jTextField6.setText(count);
}
} catch (SQLException ex) {
Logger.getLogger(AdminInfo.class.getName()).log(Level.SEVERE, null, ex);
}
現在我用這個查詢
String qry1=select sum(case when maths = 'ABSENT' then 1 else 0 end) +
sum(case when ca = 'ABSENT' then 1 else 0 end) +
sum(case when cn = 'ABSENT' then 1 else 0 end)
from attendance_table;
此查詢的總和jTextField5設置。你能告訴我如何使用這個查詢嗎?
目前還不清楚你在問什麼。請澄清。 –