I want to show all records in the student table - name and number - and then in the right column, show the percentage of attendance. Let's see:
SELECT nome, numero, (
(
SELECT COUNT(aluno.numero)
FROM aluno
JOIN aula ON aluno.id_aula_aluno = aula.id_aula
WHERE aula.id_uc_aula =4
AND aula.id_professor_aula =1 AND aluno.numero=11111) /
(SELECT COUNT( aula.id_uc_aula )
FROM aula
WHERE aula.id_uc_aula =4
AND aula.id_professor_aula =1 )
) AS Percentagem
FROM aluno
JOIN aula
WHERE aula.id_uc_aula =4
AND aula.id_professor_aula =1
AND aluno.id_aula_aluno = aula.id_aula
That is, in the second select is only to be counted for a student and I wanted for each id automatically. The split is between the two select.