");
out.println("");
out.println("Keskmine | Hääli | Laulu nimi | Esitaja | Hinda laulu | Statistika | ");
String paring4 = "DELETE FROM abi";
st.executeUpdate(paring4);
String paring1 = "INSERT INTO abi select l.id, l.laul, l.esitaja, l.hinnatud, AVG(h.hinne) AS keskmine FROM vaprad AS l LEFT JOIN vaprate_hinded AS h ON l.id=h.laulu_id GROUP BY l.id, l.laul, l.esitaja, l.hinnatud";
st.executeUpdate(paring1);
String paring2 = "SELECT * FROM abi ORDER BY keskmine DESC, esitaja ASC;";
ResultSet rs=st.executeQuery(paring2);
String taust = "white";
int i = 0;
while(rs.next()){
i = i + 1;
String id = rs.getString("id");
String laul = rs.getString("laul");
String esitaja = rs.getString("esitaja");
int hinnatud = rs.getInt("hinnatud");
double keskmine = rs.getDouble("keskmine");
keskmine = keskmine * 100;
keskmine = (int)keskmine;
keskmine = keskmine/100;
String paring3 = "SELECT COUNT(*) as hindeid from vaprate_hinded WHERE laulu_id = " + id + ";";
ResultSet hin=tt.executeQuery(paring3);
hin.next();
int hindeid = hin.getInt("hindeid");
if(i >= 8 && hindeid != 0){
taust = "red";
}
else if(hindeid == 0){
taust = "yellow";
}
else{
taust = "white";
}
out.println("" + keskmine + " | " + hindeid + " | " + laul + " | " + esitaja + " | ");
if(hinnatud == 0){
out.println("1|2|3|4|5 | ");
}else if(hinnatud == 1){
out.println("1|2|3|4|5 | ");
}
out.println("Vaata... | ");
}
cn.close();
out.println(" ");
out.println(" |
");
if(i == 9){
out.println("