err:=DBQueryRow("SELECT SUM(A.points * A.coeff) AS score FROM (SELECT S.id_team, E.gain AS points, coeff FROM (SELECT id_team, id_exercice, MIN(time) AS time, "+fmt.Sprintf("%f",FirstBlood)+" AS coeff FROM exercice_solved GROUP BY id_exercice UNION SELECT id_team, id_exercice, time, coefficient AS coeff FROM exercice_solved) S INNER JOIN exercices E ON S.id_exercice = E.id_exercice UNION ALL SELECT D.id_team, H.cost AS points, -1.0 AS coeff FROM team_hints D INNER JOIN exercice_hints H ON H.id_hint = D.id_hint UNION ALL SELECT id_team, ((FLOOR(COUNT(*)/10 - 1) * (FLOOR(COUNT(*)/10)))/0.2 + (FLOOR(COUNT(*)/10) * (COUNT(*)%10)))/"+fmt.Sprintf("%f",1/SubmissionCostBase)+" AS points, -1 AS coeff FROM exercice_tries GROUP BY id_exercice HAVING points != 0) A WHERE A.id_team = ? GROUP BY A.id_team",t.Id).Scan(&nb)
ifrows,err:=DBQuery("SELECT A.id_team, SUM(A.points * A.coeff) AS score, MAX(A.time) AS time FROM (SELECT S.id_team, S.time, E.gain AS points, coeff FROM (SELECT id_team, id_exercice, MIN(time) AS time, "+fmt.Sprintf("%f",FirstBlood)+" AS coeff FROM exercice_solved GROUP BY id_exercice UNION SELECT id_team, id_exercice, time, coefficient AS coeff FROM exercice_solved) S INNER JOIN exercices E ON S.id_exercice = E.id_exercice UNION ALL SELECT D.id_team, D.time, H.cost AS points, -1.0 AS coeff FROM team_hints D INNER JOIN exercice_hints H ON H.id_hint = D.id_hint UNION ALL SELECT id_team, MAX(time) AS time, ((FLOOR(COUNT(*)/10 - 1) * (FLOOR(COUNT(*)/10)))/0.2 + (FLOOR(COUNT(*)/10) * (COUNT(*)%10)))/"+fmt.Sprintf("%f",1/SubmissionCostBase)+" AS points, -1 AS coeff FROM exercice_tries GROUP BY id_exercice HAVING points != 0) A GROUP BY A.id_team ORDER BY score DESC, time ASC");err!=nil{