projet de fin d'etude
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
-40%
Le deal à ne pas rater :
Tefal Ingenio Emotion – Batterie de cuisine 10 pièces (induction, ...
59.99 € 99.99 €
Voir le deal

bdd compte rendu

Aller en bas

bdd compte rendu Empty bdd compte rendu

Message par Admin Ven 23 Oct - 20:59


/*TEST : requete afficher joueur*/
/*select * from joueur;*/
/* Question a) de l'exercice de TD */
/*select LIEUTOURNOI, ANNEE, NuJOUEUR
from GAIN
where NOMSPONSOR = 'Peugeot' and ANNEE >= '1990' and ANNEE <= '1994';*/
/* Question b) de l'exercice de TD */
/*select NOM, ANNEE
from JOUEUR J, GAIN G
where J.NuJOUEUR = G.NuJOUEUR and LIEUTOURNOI = 'Roland Garros' and ANNEE = '1994';*/
/* Question c) de l'exercice de TD */
/*select NOM, NATIONALITE
from JOUEUR J, GAIN G1, GAIN G2
where G1.NuJOUEUR = G2.NuJOUEUR and G1.NuJOUEUR = J.NuJOUEUR and G1.LIEUTOURNOI = 'Roland Garros' and G1.ANNEE = '1992' and G2.LIEUTOURNOI = 'Wimbledon' and G2.ANNEE = '1992';*/
/* Question d) de l'exercice de TD */
/*select NOM, NATIONALITE
from JOUEUR J, GAIN G, RENCONTRE R
where J.NuJOUEUR = NuGAGNANT and J.NuJOUEUR = G.NuJOUEUR and R.LIEUTOURNOI = 'Roland Garros' and G.NOMSPONSOR = 'Peugeot';*/
/* Question e) de l'exercice de TD */
/*select NOM
from JOUEUR J
where J.NuJOUEUR not in(select NuJOUEUR from GAIN where LIEUTOURNOI = 'Roland Garros' and PRIME < 1e6 );*/
/* ???????????????????? ????????????????? Question f) de l'exercice de TD */
/*select NuPERDANT
from RENCONTRE
where LIEUTOURNOI = 'Wimbledon' and NuPERDANT not in (select NuGAGNANT from RENCONTRE where LIEUTOURNOI= 'Wimbledon')
and NuPERDANT in (select NuGAGNANT from RENCONTRE where LIEUTOURNOI = 'Roland Garros') and NuPERDANT not in (select NuPERDANT from RENCONTRE where LIEUTOURNOI = 'Roland Garros');*/
/* Question g) de l'exercice de TD */
/*select distinct NOM, LIEUTOURNOI, ANNEE
from JOUEUR J, RENCONTRE R1
where J.NuJOUEUR = R1.NuGAGNANT and R1.NuGAGNANT not in( select R2.NuPERDANT from RENCONTRE R2 where R1.LIEUTOURNOI = R2.LIEUTOURNOI and R1.ANNEE = R2.ANNEE);*/
/* Question h) de l'exercice de TD */
select NOM
from JOUEUR
Where NuJOUEUR in ( select NuGAGNANT from RENCONTRE R1 where R1.NuGAGNANT not in (
/****h,i,j****/


/* Question k) de l'exercice de TD */
/*select NuJOUEUR
from GAIN
group by NuJOUEUR
having count (distinct NOMSPONSOR) >=2;*/
/* Question l) de l'exercice de TD */
/*select NuJOUEUR
from GAIN
group by NuJOUEUR
having count (distinct NOMSPONSOR) = 2;*/

/* ----------------------------------------------------------------------
Fichier tennis.sql: Création de la base tennis
--------------------------------------------------------------------- */

drop table Joueur;
drop table Rencontre;
drop table Gain;

create table JOUEUR
( NuJOUEUR int,
NOM varchar(12),
PRENOM varchar(14),
AnNaiss smallint,
NATIONALITE varchar(12));

create table RENCONTRE
( NuGAGNANT int,
NuPERDANT int,
LIEUTOURNOI varchar(15),
ANNEE smallint);

create table GAIN
( NuJOUEUR int,
LIEUTOURNOI varchar(15),
ANNEE smallint,
PRIME decimal,
NOMSPONSOR varchar(10));


insert into JOUEUR
values (1, 'MARTINEZ', 'Conchita', 1972, 'Espagne');
insert into JOUEUR
values (2, 'NAVRATILOVA', 'Martina', 1957, 'Etats-Unis');
insert into JOUEUR
values (3, 'GRAF', 'Steffi', 1969, 'Allemagne');
insert into JOUEUR
values (4, 'HALARD', 'Julie', 1970, 'France');
insert into JOUEUR
values (5, 'PIERCE', 'Mary', 1975, 'France');
insert into JOUEUR
values (6, 'EDBERG', 'Stephan', 1966, 'Suede');
insert into JOUEUR
values (7, 'LARSSON', 'Magnus', 1970, 'Suede');
insert into JOUEUR
values (8, 'LECONTE', 'Henri', 1963, 'France');
insert into JOUEUR
values (9, 'FORGET', 'Guy', 1965, 'France');
insert into JOUEUR
values (10, 'FLEURIAN', 'Jean-Philippe', 1965, 'France');
insert into JOUEUR
values (11, 'WILANDER', 'Mats', 1964, 'Suede');
insert into JOUEUR
values (12, 'CONNORS', 'Jimmy', 1952, 'Etats-Unis');
insert into JOUEUR
values (13, 'McENROE', 'John', 1959, 'Etats-Unis');
insert into JOUEUR
values (14, 'SAMPRAS', 'Pete', 1972, 'Etats-Unis');

insert into RENCONTRE
values (13, 9, 'Roland Garros', 1990);
insert into RENCONTRE
values (11, 12, 'Roland Garros', 1990);
insert into RENCONTRE
values (13, 11, 'Roland Garros', 1990);
insert into RENCONTRE
values (2, 3, 'Roland Garros', 1990);
insert into RENCONTRE
values (13, 12, 'Roland Garros', 1992);
insert into RENCONTRE
values (6, 14, 'Roland Garros', 1992);
insert into RENCONTRE
values (11, 9, 'Roland Garros', 1992);
insert into RENCONTRE
values (8, 7, 'Roland Garros', 1992);
insert into RENCONTRE
values (13, 8, 'Roland Garros', 1992);
insert into RENCONTRE
values (6, 11, 'Roland Garros', 1992);
insert into RENCONTRE
values (13, 6, 'Roland Garros', 1992);
insert into RENCONTRE
values (2, 3, 'Roland Garros', 1992);
insert into RENCONTRE
values (14, 10, 'Roland Garros', 1994);
insert into RENCONTRE
values (8, 9, 'Roland Garros', 1994);
insert into RENCONTRE
values (14, 8, 'Roland Garros', 1994);
insert into RENCONTRE
values (2, 4, 'Roland Garros', 1994);
insert into RENCONTRE
values (1, 3, 'Roland Garros', 1994);
insert into RENCONTRE
values (2, 1, 'Roland Garros', 1994);
insert into RENCONTRE
values (11, 8, 'Wimbledon', 1989);
insert into RENCONTRE
values (12, 13, 'Wimbledon', 1989);
insert into RENCONTRE
values (11, 12, 'Wimbledon', 1989);
insert into RENCONTRE
values (3, 2, 'Wimbledon', 1989);
insert into RENCONTRE
values (14, 13, 'Wimbledon', 1992);
insert into RENCONTRE
values (6, 9, 'Wimbledon', 1992);
insert into RENCONTRE
values (6, 14, 'Wimbledon', 1992);
insert into RENCONTRE
values (3, 5, 'Wimbledon', 1992);
insert into RENCONTRE
values (2, 4, 'Wimbledon', 1992);
insert into RENCONTRE
values (3, 2, 'Wimbledon', 1992);
insert into RENCONTRE
values (14, 10, 'Wimbledon', 1993);
insert into RENCONTRE
values (7, 9, 'Wimbledon', 1993);
insert into RENCONTRE
values (14, 7, 'Wimbledon', 1993);
insert into RENCONTRE
values (1, 5, 'Wimbledon', 1993);
insert into RENCONTRE
values (2, 4, 'Wimbledon', 1993);
insert into RENCONTRE
values (1, 2, 'Wimbledon', 1993);
insert into RENCONTRE
values (12, 9, 'Flushing Meadow', 1989);
insert into RENCONTRE
values (2, 3, 'Flushing Meadow', 1989);
insert into RENCONTRE
values (12, 7, 'Flushing Meadow', 1991);

insert into GAIN
values (14, 'Roland Garros', 1992, 0.2e6, 'Peugeot');
insert into GAIN
values (14, 'Roland Garros', 1994, 1.8e6, 'Reebok');
insert into GAIN
values (14, 'Wimbledon', 1992, 0.7e6, 'Peugeot');
insert into GAIN
values (14, 'Wimbledon', 1993, 1.4e6, 'Peugeot');
insert into GAIN
values (13, 'Roland Garros', 1990, 1.1e6, 'Kennex');
insert into GAIN
values (13, 'Roland Garros', 1992, 1.5e6, 'Kennex');
insert into GAIN
values (13, 'Wimbledon', 1989, 0.35e6, 'Donnay');
insert into GAIN
values (13, 'Wimbledon', 1992, 0.4e6, 'Kennex');
insert into GAIN
values (12, 'Roland Garros', 1990, 0.4e6, 'Dunlop');
insert into GAIN
values (12, 'Roland Garros', 1992, 0.2e6, 'Dunlop');
insert into GAIN
values (12, 'Wimbledon', 1989, 0.6e6, 'Dunlop');
insert into GAIN
values (12, 'Flushing Meadow', 1989, 1.6e6, 'Dunlop');
insert into GAIN
values (12, 'Flushing Meadow', 1991, 1.8e6, 'Lacoste');
insert into GAIN
values (11, 'Roland Garros', 1990, 0.7e6, 'Kennex');
insert into GAIN
values (11, 'Roland Garros', 1992, 0.5e6, 'Kennex');
insert into GAIN
values (11, 'Wimbledon', 1989, 1.0e6, 'Dunlop');
insert into GAIN
values (10, 'Roland Garros', 1994, 0.6e6, 'Peugeot');
insert into GAIN
values (10, 'Wimbledon', 1993, 0.5e6, 'Peugeot');
insert into GAIN
values (8, 'Roland Garros', 1992, 0.5e6, 'Lacoste');
insert into GAIN
values (8, 'Roland Garros', 1994, 1.0e6, 'Reebok');
insert into GAIN
values (8, 'Wimbledon', 1989, 0.35e6, 'Peugeot');
insert into GAIN
values (7, 'Roland Garros', 1992, 0.2e6, 'Donnay');
insert into GAIN
values (7, 'Wimbledon', 1993, 0.8e6, 'Reebok');
insert into GAIN
values (7, 'Flushing Meadow', 1991, 1.0e6, 'Donnay');
insert into GAIN
values (6, 'Roland Garros', 1992, 0.9e6, 'Dunlop');
insert into GAIN
values (6, 'Wimbledon', 1992, 1.2e6, 'Dunlop');
insert into GAIN
values (5, 'Wimbledon', 1992, 0.3e6, 'Dunlop');
insert into GAIN
values (5, 'Wimbledon', 1993, 0.35e6, 'Reebok');
insert into GAIN
values (4, 'Roland Garros', 1994, 0.4e6, 'Lacoste');
insert into GAIN
values (4, 'Wimbledon', 1992, 0.3e6, 'Lacoste');
insert into GAIN
values (4, 'Wimbledon', 1993, 0.35e6, 'Lacoste');
insert into GAIN
values (9, 'Roland Garros', 1990, 0.4e6, 'Peugeot');
insert into GAIN
values (9, 'Roland Garros', 1992, 0.2e6, 'Peugeot');
insert into GAIN
values (9, 'Roland Garros', 1994, 0.6e6, 'Reebok');
insert into GAIN
values (9, 'Wimbledon', 1992, 0.4e6, 'Peugeot');
insert into GAIN
values (9, 'Wimbledon', 1993, 0.5e6, 'Reebok');
insert into GAIN
values (9, 'Flushing Meadow', 1989, 0.9e6, 'Lacoste');
insert into GAIN
values (3, 'Roland Garros', 1990, 0.5e6, 'Donnay');
insert into GAIN
values (3, 'Roland Garros', 1992, 0.55e6, 'Donnay');
insert into GAIN
values (3, 'Roland Garros', 1994, 0.4e6, 'Reebok');
insert into GAIN
values (3, 'Wimbledon', 1989, 0.75e6, 'Donnay');
insert into GAIN
values (3, 'Wimbledon', 1992, 0.85e6, 'Donnay');
insert into GAIN
values (3, 'Flushing Meadow', 1989, 0.7e6, 'Donnay');
insert into GAIN
values (2, 'Roland Garros', 1990, 0.8e6, 'Vittel');
insert into GAIN
values (2, 'Roland Garros', 1992, 0.9e6, 'Vittel');
insert into GAIN
values (2, 'Roland Garros', 1994, 1.2e6, 'Donnay');
insert into GAIN
values (2, 'Wimbledon', 1989, 0.4e6, 'Vittel');
insert into GAIN
values (2, 'Wimbledon', 1992, 0.5e6, 'Vittel');
insert into GAIN
values (2, 'Wimbledon', 1993, 0.6e6, 'Donnay');
insert into GAIN
values (2, 'Flushing Meadow', 1989, 1.0e6, 'Vittel');
insert into GAIN
values (1, 'Wimbledon', 1993, 0.9e6, 'Nike');
insert into GAIN
values (1, 'Roland Garros', 1994, 0.8e6, 'Nike');

/*EXERCICE A

SELECT NUJOUEUR, ANNEE, LIEUTOURNOI
FROM GAIN
WHERE NOMSPONSOR ='Peugeot'
AND ANNEE BETWEEN '1990' AND '1994';*/

/*EXERCICE B

SELECT NOM, ANNAISS
FROM JOUEUR J, GAIN G
WHERE J.NUJOUEUR = G.NUJOUEUR
AND LIEUTOURNOI = 'ROLAND GARROS'
AND ANNEE = '1994';*/

/*EXERCICE C
SELECT NOM, NATIONALITE
FROM GAIN G1, GAIN G2, JOUEUR J
WHERE G1.NUJOUEUR = G2.NUJOUEUR
AND G1.NUJOUEUR = J.NUJOUEUR
AND G1.LIEUTOURNOI = 'ROLAND GARROS'
AND G1.ANNEE = '1992'
AND G2.LIEUTOURNOI = 'WIMBLEDON'
AND G2.ANNEE = '1992';*/

/*EXERCICE D
SELECT NOM, NATIONALITE
FROM JOUEUR
WHERE NUJOUEUR IN(SELECT NUJOUEUR
FROM GAIN
WHERE NOMSPONSOR = 'PEUGEOT')
AND NUJOUEUR IN(SELECT NUGAGNANT
FROM RENCONTRE
WHERE LIEUTOURNOI = 'ROLAND GARROS'); */

/*EXERCICE E
SELECT NOM
FROM JOUEUR J
WHERE NUJOUEUR IN (SELECT NUJOUEUR
FROM GAIN G1
WHERE LIEUTOURNOI = 'ROLAND GARROS')
AND NOT EXISTS(SELECT *
FROM GAIN G2
WHERE G2.NUJOUEUR = J.NUJOUEUR
AND G2.LIEUTOURNOI = 'ROLAND GARROS'
AND PRIME <=1E6);*/

/*EXERCICE F
SELECT DISTINCT NUPERDANT
FROM RENCONTRE
WHERE LIEUTOURNOI = 'WIMBLEDON'
AND NUPERDANT NOT IN (SELECT NUGAGNANT
FROM RENCONTRE
WHERE LIEUTOURNOI ='WIMBLEDON')
AND NUPERDANT IN (SELECT NUGAGNANT
FROM RENCONTRE
WHERE LIEUTOURNOI = 'ROLAND GARROS')
AND NUPERDANT NOT IN (SELECT NUPERDANT
FROM RENCONTRE
WHERE LIEUTOURNOI ='ROLAND GARROS');*/


/*EXERCICE G
SELECT DISTINCT NOM, LIEUTOURNOI,ANNEE
FROM RENCONTRE R1, JOUEUR J
WHERE J.NuJOUEUR = R1.NuGAGNANT
AND NOT EXISTS(SELECT *
FROM RENCONTRE R2
WHERE R2.NuPERDANT = R1.NuGAGNANT
AND R1.LIEUTOURNOI = R2.LIEUTOURNOI
AND R1.ANNEE = R2.ANNEE
);*/


/*EXERCICE H
SELECT DISTINCT NOM
FROM JOUEUR J, RENCONTRE R1
WHERE J.NuJOUEUR IN (SELECT NuGAGNANT
FROM RENCONTRE R2
WHERE R2.NuGAGNANT NOT IN(SELECT NuPERDANT
FROM RENCONTRE R2
WHERE R1.LIEUTOURNOI = R2.LIEUTOURNOI
AND R1.ANNEE = R2.ANNEE
))
OR J.NuJOUEUR IN (SELECT NuJOUEUR
FROM GAIN G
WHERE G.PRIME>= 1E6);*/


/*EXERCICE I
SELECT NOM
FROM JOUEUR J
WHERE NOT EXISTS (SELECT *
FROM GAIN G1
WHERE ANNEE = '1994'
AND NOT EXISTS (SELECT *
FROM GAIN G2
WHERE G1.NUJOUEUR = G2.NuJOUEUR
AND G1.ANNEE = G2.ANNEE
AND G1.LIEUTOURNOI = G2.LIEUTOURNOI));*/


/*EXERCICE J
SELECT COUNT(*)
FROM GAIN
WHERE LIEUTOURNOI = 'Wimbledon'
AND ANNEE = '1993';*/

/*EXERCICE K
SELECT NuJOUEUR
FROM GAIN
GROUP BY NuJOUEUR
HAVING COUNT (DISTINCT NOMSPONSOR)>=2;*/


/*EXERCICE L
SELECT NuJOUEUR
FROM GAIN
GROUP BY NuJOUEUR
HAVING COUNT (DISTINCT NOMSPONSOR)=2;*/




/*EXERCICE M
SELECT ANNEE, AVG(PRIME)AS AVERAGEPRIME
FROM GAIN
GROUP BY ANNEE;*/


/*EXERCICE N
SELECT MAX(PRIME), NOM
FROM GAIN, JOUEUR
WHERE ANNEE = '1992'
GROUP BY NOM;*/

/*EXERCICE O
SELECT SUM(PRIME), NuJOUEUR
FROM GAIN
WHERE ANNEE = '1992'
GROUP BY NuJOUEUR
ORDER BY SUM(PRIME)DESC;*/

/*EXERCICE P
SELECT DISTINCT NOM, PRENOM
FROM RENCONTRE R1, JOUEUR J
WHERE R1.NuGAGNANT = J.NuJOUEUR
AND NOT EXISTS(SELECT *
FROM RENCONTRE R2
WHERE R2.NuPERDANT = R1.NuGAGNANT
AND R2.ANNEE = '1992'
AND R2.LIEUTOURNOI = 'ROLAND GARROS');*/

/*EXERCICE Q*/

SELECT DISTINCT NOM
FROM JOUEUR, GAIN
WHERE EXISTS(SELECT NOM
FROM GAIN G2
WHERE G2.LIEUTOURNOI = 'ROLAND GARROS');


/*EXERCICE R*/



/*EXERCICE S
SELECT NOMSPONSOR
FROM GAIN
WHERE NOT EXISTS(SELECT *
FROM GAIN G2)*/


/*EXERCICE T
SELECT NATIONALITE,
FROM JOUEUR J,RENCONTRE R1
WHERE J.NuJOUEUR = R1.NuGAGNANT
AND NOT EXISTS(SELECT *
FROM RENCONTRE R2
WHERE R2.NuPERDANT = R1.NuGAGNANT
AND R2.ANNEE = R1.ANNEE
AND R2.LIEUTOURNOI = R1.LIEUTOURNOI)
GROUP BY NATIONALITE;*/

/H/ select nom
from JOUEUR
where NuJOUEUR in ( select nugagnant
from RENCONTRE R1
where R1.NuGAGNANT not IN ( select NuPERDANT
from RENCONTRE R2
where R2.LIEUTOURNOI = R1.LIEUTOURNOI))
or NuJOUEUR in ( select NuJOUEUR
from GAIN
where PRIME > 1e6 );

/I/ select distinct NOM
from joueur, RENCONTRE
where ANNEE = '1994' and NuJOUEUR = NuGAGNANT or NuJOUEUR = NuPERDANT;

/J/ select COUNT (distinct G.Nujoueur)
from GAIN G , RENCONTRE R
where G.LIEUTOURNOI = ' Wimbledon' and G.annee = '1993' and G.NuJOUEUR = NuGAGNANT OR G.NuJOUEUR = NuPERDANT;

/K/ select distinct nujoueur
from GAIN g
where g.NuJOUEUR in (select nujoueur
from GAIN G2
Where g.NuJOUEUR = g2.NuJOUEUR and g.NOMSPONSOR != g2.NOMSPONSOR);
/L/ select distinct nujoueur
from GAIN
group by NuJOUEUR
having count (distinct nomsponsor) = 2;

/M/ select ANNEE ,AVG(prime)
from GAIN
group by ANNEE

/N/ select NOM , prime
from joueur J, GAIN G
where G.ANNEE = '1992' and J.NuJOUEUR = G.NuJOUEUR and PRIME = (select MAX(prime)
from joueur J, GAIN G
where G.ANNEE = '1992' and J.NuJOUEUR = G.NuJOUEUR);
/O/ select distinct nujoueur, sum(prime)
from gain
where ANNEE = '1992'
group by nujoueur
order by sum(prime) desc;

/P/ select distinct nom ,prenom
from JOUEUR, RENCONTRE r
where nujoueur = nugagnant and r.ANNEE = '1992' and r.LIEUTOURNOI = 'Roland Garros' and Nugagnant not in ( select nuperdant
from RENCONTRE e
where e.ANNEE = '1992' and e.LIEUTOURNOI = 'Roland Garros');
/Q/ select nom
from JOUEUR
where NuJOUEUR not exists ( select lieutournoi, annee
from gain
where LIEUTOURNOI = 'Roland Garros'
group by LIEUTOURNOI,annee);

SELECT *
FROM JOUEUR;

SELECT *
FROM GAIN;

SELECT *
FROM RENCONTRE;

/* a */
SELECT nujoueur, lieuTournoi, annee
FROM GAIN
WHERE nomsponsor = 'Peugeot' and annee >= '1990' and annee <= '1994';

/* b */
SELECT nom, anNaiss
FROM JOUEUR j, GAIN g
WHERE j.nujoueur = g.nujoueur and g.lieuTournoi = 'Roland Garros' and annee = '1994';

/* c */
Select nom, nationalite
From Joueur j, Gain g1, Gain g2
Where j.nujoueur = g1.nujoueur and j.nujoueur = g2.nujoueur and g1.lieuTournoi = 'Roland Garros' and g1.annee = '1992'
and g2.lieuTournoi = 'Wimbledon' and g2.annee = '1992';

/* d */
Select nom, nationalite
From Joueur j
Where EXISTS ( Select *
From Gain g
where g.nujoueur = j.nujoueur and nomSponsor = 'Peugeot')
and nujoueur IN (Select nugagnant
From Rencontre
where nujoueur = nuGagnant);

/* e */
SELECT DISTINCT nom
FROM JOUEUR J, GAIN G2
WHERE not exists ( SELECT *
FROM GAIN G
WHERE G.nujoueur = J.nujoueur
and G.lieuTournoi = 'Roland Garros'
AND prime <= 1e6)
and G2.lieuTournoi = 'Roland Garros'
and G2.nujoueur = J.nujoueur;

/* f */
SELECT DISTINCT R.nuperdant
FROM RENCONTRE R
WHERE R.lieuTournoi ='Wimbledon'

AND R.nuperdant NOT IN(SELECT nugagnant
FROM RENCONTRE R2
WHERE R2.lieuTournoi='Wimbledon')
AND R.nuperdant IN(SELECT nugagnant
FROM RENCONTRE R4
WHERE R4.lieuTournoi = 'Roland Garros')
AND R.nuperdant NOT IN(SELECT nuperdant
FROM RENCONTRE R3
WHERE R3.lieuTournoi='Roland Garros');

/* g */
SELECT DISTINCT nom, lieuTournoi,ANNEE, NATIONALITE
FROM JOUEUR J, RENCONTRE R
WHERE J.nujoueur=R.nugagnant
AND NOT EXISTS (SELECT *
FROM RENCONTRE R2
WHERE J.nujoueur=R2.nuperdant
AND R.annee=R2.annee
AND R.lieuTournoi=R2.lieuTournoi)
order by NATIONALITE ;

/* h */
SELECT DISTINCT nom
FROM JOUEUR J, RENCONTRE R
WHERE J.nujoueur=R.nugagnant
AND NOT EXISTS (SELECT *
FROM RENCONTRE R2
WHERE J.nujoueur=R2.nuperdant
AND R.annee=R2.annee
AND R.lieuTournoi=R2.lieuTournoi)
OR J.nujoueur IN(SELECT G.nujoueur
FROM Gain G
WHERE prime>1e6);

/* i */
SELECT nom
FROM JOUEUR J
WHERE NOT EXISTS(SELECT *
FROM GAIN G
WHERE G.annee='1994'
AND NOT EXISTS(SELECT *
FROM GAIN G2
WHERE G.annee=G2.annee
AND J.nujoueur=G2.nujoueur));

/* j */
SELECT COUNT(*)
FROM JOUEUR J
WHERE J.nujoueur IN(SELECT G.nujoueur
FROM GAIN G
WHERE G.lieuTournoi = 'Wimbledon'
AND G.annee = '1993');

/* k */
Select nujoueur
From gain
group by nujoueur
having COUNT(distinct nomSponsor) >= 2;

/* l */
Select distinct g1.nujoueur
From gain g1, gain g2
where g1.nujoueur = g2.nujoueur and g1.nomSponsor <> g2.nomSponsor
and not exists (Select *
From gain g3
Where g3.nujoueur = g1.nujoueur
and g1.nomSponsor <> g3.nomSponsor
and g2.nomSponsor <> g3.nomSponsor);

/* m */
Select annee, AVG(prime)
From gain
group by annee;

/* n */
Select distinct prime, nom
From Joueur j, gain g
Where j.nujoueur = g.nujoueur and g.annee = '1992'
and not exists (Select *
From gain g2
Where g2.annee = g.annee and g2.prime > g.prime);

/* o */
Select nom, g.nujoueur, SUM(prime)
From gain g, joueur j
Where g.annee = '1992' and g.nujoueur = j.nujoueur
group by g.nujoueur, nom
order by SUM(prime) desc;

/* p */
Select nom, prenom
From joueur j, gain g
Where j.nujoueur = g.nujoueur and lieuTournoi = 'Roland Garros' and annee = '1992'
and j.nujoueur not in (Select nuperdant
From rencontre
Where lieuTournoi = 'Roland Garros' and annee = '1992');

/* q */
Select nom, prenom
From Joueur j
where not exists (Select *
From gain g1
Where g1.lieuTournoi ='Roland Garros'
and not exists (Select *
From gain g2
Where j.nujoueur = g2.nujoueur
and g1.annee = g2.annee));

/* r */
Select distinct j1.nom, j2.nom
From Joueur j1, Joueur j2, rencontre r1
Where j1.nujoueur = r1.nuGagnant and j2.nujoueur = r1.nuPerdant
and not exists (Select *
From rencontre r2
Where j1.nujoueur = r2.nuPerdant and j2.nujoueur = r2.nuGagnant);

/* s */
Select distinct nomSponsor
From gain g1
Where not exists (Select *
From gain g2
Where not exists (Select *
From gain g3
Where g1.nomSponsor = g3.nomSponsor
and g2.lieuTournoi = g3.lieuTournoi
and g2.annee = g3.annee));

/* t */
Select nationalite
From Joueur j1
Where not exists (Select *
From rencontre r1
Where not exists (Select *
From rencontre r2, Joueur j2
Where r1.nugagnant = r2.nuperdant
and r1.lieuTournoi = r2.lieuTournoi
and r1.annee = r2.annee
and j2.nationalite <> j1.nationalite
));

Select distinct j1.nationalite, r1.annee
From Joueur j1, rencontre r1
Where j1.nujoueur = r1.nugagnant
and not exists (Select *
From rencontre r2
Where r1.nugagnant = r2.nuperdant
and r1.lieuTournoi = r2.lieuTournoi
and r1.annee = r2.annee)
and not exists (Select *
From rencontre r3
Where j1.nujoueur = r3.nuperdant
and r1.lieuTournoi <> r3.lieuTournoi
and r1.annee <> r3.annee)
group by annee, nationalite;

Select nationalite, annee
From Joueur j, rencontre r1
Where r1.nugagnant = j.nujoueur
and not exists (Select *
From rencontre r2
Where r2.nuperdant = r1.nugagnant
and r2.lieuTournoi = r1.lieuTournoi
and r2.annee = r1.annee)
group by nationalite, annee;
having COUNT(distinct annee)=6; = (Select COUNT(distinct annee)
From rencontre r1);

TME :
H°) select NOM
from JOUEUR
Where NuJOUEUR in ( select NuGAGNANT from RENCONTRE R1 where R1.NuGAGNANT not in (

i°) select NOM
from JOUEUR J
where not exists (select * from GAIN G where ANNEE ='1994' and not exists ( select * from GAIN G2 where J.NuJOUEUR = G2.NuJOUEUR and G2.LIEUTOURNOI = G1.LIEUTOURNOI and G2.ANNEE = G1.ANNEE));

J°) select count
from GAIN
where LIEUTOURNOI='Wb' and ANNEE='1993';

K°) select NuJOUEUR
from GAIN
group by NuJOUEUR
having count (distinct NOMSPONSOR) >=2;

K*°)
select NuJOUEUR
from GAIN G1, GAIN G2
where G1.NuJOUEUR = G2.NuJOUEUR and
G1.NOMSPONSOR <> G2.NOMSPONSOR and not exists (select * from GAIN G3 where G3 NuJOUEUR

L°) select NuJOUEUR
from GAIN
group by NuJOUEUR
having count (distinct NOMSPONSOR) = 2;

Admin
Admin

Messages : 51
Date d'inscription : 23/04/2015

https://projetfindetude.forumactif.org

Revenir en haut Aller en bas

Revenir en haut


 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum