0% found this document useful (0 votes)
10 views3 pages

EXAMEN DATABASES Q2 SQL - 022937

The document contains SQL commands and results related to a database named 'attribution', focusing on the tables 'professeur' and 'cours'. It includes queries for altering tables, retrieving professor data ordered by hire date, calculating honoraria based on course volume, counting courses per professor, and summarizing total course volume by diploma. The results show the relationships between professors and courses, along with their respective details.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

EXAMEN DATABASES Q2 SQL - 022937

The document contains SQL commands and results related to a database named 'attribution', focusing on the tables 'professeur' and 'cours'. It includes queries for altering tables, retrieving professor data ordered by hire date, calculating honoraria based on course volume, counting courses per professor, and summarizing total course volume by diploma. The results show the relationships between professors and courses, along with their respective details.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

EXAMEN DATABASES Q2:SQL

mysql> use attribution;


Database changed
……………………………………………………………………………
mysql> select*from professeur;
+-----------+---------+----------+--------------+
| matricule | nom | diplome | dateembauche |
+-----------+---------+----------+--------------+
| 123/123a | alain | master | 2010-02-12 |
| 456/456a | sylvain | master | 2016-12-22 |
| 789/789a | kevin | doctorat | 2019-04-25 |
+-----------+---------+----------+--------------+

mysql> select*from cours;


+----------+------------+---------------+
| numcours | intitule | volumehoraire |
+----------+------------+---------------+
| b1 | informatiq | 45 |
| b2 | maths | 60 |
| b3 | algo | 75 |
| b4 | biolgie | 30 |
+----------+------------+---------------+
……………………………………………………………………………..

Q1
mysql> alter table cours

-> add column prof varchar(20);


Query OK, 4 rows affected (1.12 sec)
Records: 4 Duplicates: 0 Warnings: 0
Q2
mysql> select * from professeur

-> order by dateembauche;


+-----------+---------+----------+--------------+
| matricule | nom | diplome | dateembauche |
+-----------+---------+----------+--------------+
| 123/123a | alain | master | 2010-02-12 |
| 456/456a | sylvain | master | 2016-12-22 |
| 789/789a | kevin | doctorat | 2019-04-25 |
+-----------+---------+----------+--------------+
3 rows in set (0.00 sec)

Q3
mysql> select nom, ((sum(volumehoraire))*10000) as honoraire

-> from professeur p, cours c


-> where p.matricule=c.prof
-> group by c.prof;
+---------+-----------+
| nom | honoraire |
+---------+-----------+
| alain | 450000 |
| sylvain | 600000 |
| kevin | 1050000 |
+---------+-----------+
3 rows in set (0.06 sec)

Q4
mysql> select nom, count(numcours) as Nombre_de_cours

-> from professeur p, cours c


-> where p.matricule=c.prof
-> group by c.prof;
+---------+-----------------+
| nom | Nombre_de_cours |
+---------+-----------------+
| alain | 1|
| sylvain | 1|
| kevin | 2|
+---------+-----------------+
3 rows in set (0.00 sec)

Q5
mysql> select diplome, sum(volumehoraire) as VolHor_Total

-> from professeur p, cours c


-> where p.matricule=c.prof
-> group by p.diplome;
+----------+--------------+
| diplome | VolHor_Total |
+----------+--------------+
| master | 105 |
| doctorat | 105 |
+----------+--------------+
2 rows in set (0.00 sec)

You might also like