I leave an example implemented with a single table because I do not know the organization of the other tables.
This is the table that you use as an example:
The query is as follows:
SELECT A.id, MAX(nota) AS nota1,
(SELECT AL.nota FROM alumnos AS AL WHERE AL.id = A.id AND AL.nota <> (SELECT nota FROM alumnos AS AL2 WHERE AL2.id = AL.id ORDER BY nota DESC LIMIT 1)
ORDER BY AL.nota DESC LIMIT 1) AS nota2,
(SELECT AL.nota FROM alumnos AS AL WHERE AL.id = A.id AND AL.nota <> (SELECT nota FROM alumnos AS AL2 WHERE AL2.id = AL.id ORDER BY nota DESC LIMIT 1) AND AL.nota <> ((SELECT AL.nota FROM alumnos AS AL WHERE AL.id = A.id AND AL.nota <> (SELECT nota FROM alumnos AS AL2 WHERE AL2.id = AL.id ORDER BY nota DESC LIMIT 1)
ORDER BY AL.nota DESC LIMIT 1))
ORDER BY AL.nota DESC LIMIT 1) AS nota3
FROM alumnos AS A
GROUP BY A.id
The result is the following:
The alternative if you use a version of MariaDB more updated or MySQL Server itself would be:
SELECT A.id, MAX(nota) AS nota1,
(SELECT AL.nota FROM alumnos AS AL WHERE AL.id = A.id AND AL.nota <> (SELECT nota FROM alumnos AS AL2 WHERE AL2.id = AL.id ORDER BY nota DESC LIMIT 1)
ORDER BY AL.nota DESC LIMIT 1) AS nota2,
(SELECT AL.nota FROM alumnos AS AL WHERE AL.id = A.id AND AL.nota NOT IN (SELECT nota FROM alumnos AS AL2 WHERE AL2.id = AL.id ORDER BY AL2.nota DESC LIMIT 2)
ORDER BY AL.nota DESC LIMIT 1) AS nota3
FROM alumnos AS A
GROUP BY A.id
The problem is that:
This version of MariaDB does not support 'LIMIT & IN / ALL / ANY / SOME
subquery '
If we go to real life this would be easier with an auxiliary language PHP, Java, etc. Or even within the same MySQL using a stored procedure, any power query can be performed but sometimes it is very cumbersome to solve it only with MySQL.
To implement the previous code, you will only have to perform the corresponding JOINS where necessary. I hope it helps you.