Created
October 20, 2021 18:42
-
-
Save elyse0/23d8b528e229d7b76d7b14d87d42db7d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use colegio | |
| db.alumnos.aggregate([ | |
| {$lookup: { | |
| from: "alumnosEvalQueretaro", | |
| localField: "clave_alu", | |
| foreignField: "matricula", | |
| as: "evaluacionesAlumnos" | |
| } | |
| }, | |
| {$match: { | |
| $expr: { | |
| $gt: [{$size: "$evaluacionesAlumnos"}, 0] | |
| } | |
| } | |
| }, | |
| {$project: { | |
| _id: 0, | |
| alumno: {$concat: ["$nombre", " ", "$ap_paterno", " ", "$ap_materno"]}, | |
| clave_alu: 1, | |
| evaluacionesAlumnos: 1 | |
| } | |
| }, | |
| {$unwind: "$evaluacionesAlumnos"}, | |
| {$group: { | |
| _id: { | |
| clave_alu: "$clave_alu", | |
| alumno: "$alumno", | |
| anio: {$dateToString: {format: "%Y", date: "$evaluacionesAlumnos.fecha"}}, | |
| promedio: {$avg: "$evaluacionesAlumnos.calificacion"}, | |
| materias: {$sum: 1} | |
| } | |
| } | |
| } | |
| ]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment