Bonsoir à tous,
je débute sql, ma prof m'a demandé de réaliser certaines requêtes que voici. J'ai cependant l'impression qu'elle ne m'a pas donné tous les outils nécessaires pour les réaliser.
Un peu d'aide serait la bienvenue. Voici l'énoncé:
The schema of the database is provided below (keys are in bold underlined)
- student(sid, sname, sex, age, year)
- dept(dname, numphds)
- prof(pname, dname)
- course(cno,dname, cname)
- major(dname,sid)
- section(dname,cno,sectno,pname)
- enroll(sid,dname,cno,sectno,grade)
1. Are there any sections without professor?
Code : Sélectionner tout - Visualiser dans une fenêtre à part Select sectno from section where pname is null;
2. Are there homonymous students?
Code : Sélectionner tout - Visualiser dans une fenêtre à part Select sname, count(sname) from student group by sname having count (*)>1;
3. For each department, list the number of phds and the number of students majoring in the department
4. List the department having no student majoring in the department
<== je suis à peu près sûr que c'est pas ce qu'il faut
Code : Sélectionner tout - Visualiser dans une fenêtre à part Select dname from major where sid is null;
5. Which course has the maximum number of sections?
6. For each student, list his/her name and the average grade
Code : Sélectionner tout - Visualiser dans une fenêtre à part Select sname, avg(grade) from student, enroll where student.sid=enroll.sid group by sname;
7. For each student, list his/her name and the average grade obtained only in courses managed by the department of his/her major.
Code : Sélectionner tout - Visualiser dans une fenêtre à part Select sname, avg(grade) from student, major, enroll where student.sid=enroll.sid and enroll.dname=major.dname group by sname;
8. For each department, list the average grade of all students in all courses of the department and the average grade of only students majoring in this department (in all courses of the department).
J'ai déjà rentré les tables et quelques données sous sql developer pour tester mes requêtes. Celles que j'ai écrites fonctionnent bien. Pour le reste, je bloque.
Quelques pistes?
merci d'avance
Partager