I have 3 tables: inscricaoaluno
, inscricaoescola
and prova
, with the following structures:
PROOF
IDPROVA | DESCPROVA | TYPE | QTDEMAX
REGISTRATION
PROFESSOR | SCHOOL (IDESCOLA) | DTINSCRICAO | IDPROVA
INSCRICAOALUNO
ALUNO (IDALUNO) | SCHOOL | DTINSCRICAO | IDPROVA
According to the tipo
of the test, 'COLETIVO' or 'INDIVIDUAL' I will take all registered schools and / or all students enrolled, for this I would like to make a query to take only the quantities ... >
I'm trying to do the following:
select * from prova p
left join (
case when p.tipo='COLETIVO' then
(SELECT ie.idProva, count(ie.idEscola) as qtde FROM inscricaoescola ie
group by ie.idProva)
else
(SELECT ia.idProva, count(ia.idaluno) as qtde FROM inscricaoaluno ia
group by ia.idProva)
end as cont)
on cont.idprova = p.idprova;
In the SQLDeveloper console it appears:
"right parenthesis not found"
I would like to know if it is possible to create a Query with this structure that I tried to do / \
left join (case {condição} then {subquery} else {outra_subquery} )
If there is any I would like some light on how I can do this ..