greg6fr
Messages postés28Date d'inscriptionmercredi 20 août 2008StatutMembreDernière intervention23 janvier 2014
-
12 avril 2009 à 21:01
EricSQL
Messages postés33Date d'inscriptionsamedi 11 octobre 2008StatutMembreDernière intervention24 février 2011
-
21 juin 2009 à 13:24
bonjour a tous.
je suis un debutant et voila qu'on me confie un preojet en sql/oracle, ou je ne sais par ou debuter les amis.
pouvez vous m'aider.
VOICI L'EXERCICE
Un petit QCM est basée sur 2 tables.L'une de ces tables contient les informatons sur les sondés(nom,prenom,etc.) ainsi que leurs reponses au questions(tables T_PANEL_PNL).
L'autre table contient, elle les reponses aux questions(T_REPONSES_RPS).
-----------------------------------------------------------------------------------------------------------
TACHE: -
Il vous est demandé d'obtenir, à lo'aide d'une requete, le nombre de bonne reponses de chaque sondés. -
VOICI LE JEU D'ESSAI UTILISE: -
-----------------------------------------------------------------------------------------------------------
/** CREATION DE LA TABLE NOMMEE T_PANEL_PNL CONTENANT LE NOM DU SONDE ET LES REPONSES CHOISIES
**/
INSERT INTO T_PANEL_PNL VALUES ('Pierre',1,2,3,0,0);
INSERT INTO T_PANEL_PNL VALUES ('Paul',1,5,3,2,1);
INSERT INTO T_PANEL_PNL VALUES ('Jacques',0,3,3,2,2);
/** CREATION DE LA TABLE NOMMEE T_REPONSES_RPS CONTENANT LES REPONSES
**/
aieeeuuuuu
Messages postés698Date d'inscriptionjeudi 16 janvier 2003StatutMembreDernière intervention20 mai 20113 14 avril 2009 à 11:29
Bonjour,
La modélisation n'est pas top pour ce genre de chose (il eut fallu un table a part pour les réponses des candidats), mais si tu n'a pas moyen de modifier la strucuture de la base, tu peux faire ca :
SELECT Nom, Count(*)
FROM T_PANEL_PNL P
INNER JOIN T_REPONSES_RPS R1 ON (P.PNL_REPONSE1 =R1.RPS_REPONSE1)
INNER JOIN T_REPONSES_RPS R1 ON (P.PNL_REPONSE2 =R1.RPS_REPONSE2)
INNER JOIN T_REPONSES_RPS R1 ON (P.PNL_REPONSE3 =R1.RPS_REPONSE3)
INNER JOIN T_REPONSES_RPS R1 ON (P.PNL_REPONSE4 =R1.RPS_REPONSE4)
INNER JOIN T_REPONSES_RPS R1 ON (P.PNL_REPONSE5 =R1.RPS_REPONSE5)
UNION
SELECT Nom, 0
FROM T_PANEL_PNL P,
T_REPONSES_RPS R
WHERE P.REPONSE1 <> R.RPS_REPONSE1
AND P.REPONSE2 <> R.RPS_REPONSE2
AND P.REPONSE3 <> R.RPS_REPONSE3
AND P.REPONSE4 <> R.RPS_REPONSE4
AND P.REPONSE5 <> R.RPS_REPONSE5
C'est un peu lourd, mais vue la structure de la base, je ne vois pas comment faire une requete plus "classe"
EricSQL
Messages postés33Date d'inscriptionsamedi 11 octobre 2008StatutMembreDernière intervention24 février 2011 21 juin 2009 à 13:24
Bonjour,
comme ceci ce sera plus propre :
Select res.pnl_nom
, case PNL_REPONSE1 when RPS_REPONSE1 then 1 else 0 end
+ case PNL_REPONSE2 when RPS_REPONSE2 then 1 else 0 end
+ case PNL_REPONSE3 when RPS_REPONSE3 then 1 else 0 end
+ case PNL_REPONSE4 when RPS_REPONSE4 then 1 else 0 end
+ case PNL_REPONSE5 when RPS_REPONSE5 then 1 else 0 end
from T_PANEL_PNL res
, T_REPONSES_RPS rep
;