Kodewick
Empieza a aprender →
Mini reto←→0 / 70

Cuadro de honor

#065Mini reto7 min

El cuadro de honor del colegio solo incluye a los estudiantes con una media de 80 o más. Agrupa por estudiante, calcula la media de score de cada uno en todas las asignaturas (las notas vacías no cuentan) y quédate con los de 80 o más. Elige name y la media con ROUND(…, 1).

Las tablas
students
  • idPK
  • name
  • class
  • age
  • city
scores
  • idPK
  • student_idFK
  • subject
  • score

scores.student_id → students.id

students
idnameclassagecity
1Amy1A12Leeds
2Ben1A13York
3Cara1B12NULL
4Dan1B14Leeds
5Eva1A12Hull
6Finn1C13NULL
7Gus1C12York
7 filas
scores
idstudent_idsubjectscore
11math92
21art78
32math65
42art88
53math74
64math55
74art90
85math81
95artNULL
107math99
10 filas
query.sql
SELECT students.name, ROUND(AVG(scores.score), 1)
FROM students
JOIN scores ON scores.student_id = students.id
-- tu código aquí: GROUP BY students.name y luego HAVING para quedarte con AVG(scores.score) >= 80
;
Ctrl + Enter también ejecuta
Resultado

Ejecutar muestra lo que da tu consulta. Cuando se vea bien, Enviar.