0
I want to show all student table records - name and number - and then in the right column, show attendance percentage. 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 only this to be accounted for a student and I wanted for each id automatically. The division this between the two select.
What id_uc_aula means?
– Andrew Ribeiro
I’m not sure what you’re still wanting to do, two more important things to see, first in your second select you have one
COUNT( aula.id_uc_aula )
and thenWHERE aula.id_uc_aula =4
This at most ira returns 1 in yourCount
2º There is a need for you to check if the second select does not return a valuenull
, if this happens will return a split error see here– Marco Souza