1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
SELECT
COUNT(a.idcand) as Total, b.lautoecole
FROM
(SELECT
COUNT(test.resultat) AS TotalResultat,candidat.nom,candidat.prenom, candidat.id AS idcand, candidat.infospermis_id AS idinfos
FROM
test
INNER JOIN infos_test_candidat ON test.id = infos_test_candidat.fk_test
INNER JOIN candidat ON candidat.id = infos_test_candidat.fk_candidat
WHERE
test.resultat = 1
GROUP BY
candidat.id) a,
(SELECT
autoecole.libelleautoecole AS lautoecole,autoecole.id AS idautoecole, infospermis.id AS idinfopermis FROM autoecole
INNER JOIN infospermis ON infospermis.fk_autoecole = autoecole.id
) b
WHERE (a.idinfos = b.idinfopermis AND a.TotalResultat = 3)
GROUP BY b.idautoecole |