Atelier Base de Données SQL
Atelier Base de Données SQL
Atelier Base de Données SQL
1/
nationalite varchar(40),
sexe char(1),
service varchar(25),
--Table créée
2/
insert into employe values ( 10,'Mohamed', 'Amine', 'TUN', 27, 'M', 'Comptabilité', 1000);
insert into employe values ( 20,'Angela', 'Portenca', 'ITA', 30, 'F', 'Informatique', 1200);
insert into employe values ( 30,'Taher', 'Tlili', 'ALG', 35, 'M', 'Comptabilité', 870);
insert into employe values ( 40,'Amira', 'Tounsi', 'TUN', 47, 'F', 'Personnel', 570);
insert into employe values ( 70,'Sonia', 'Tounsi', 'TUN', 40, 'F', 'Informatique', 960);
insert into employe values ( 90,'Salah', 'Ali', 'TUN', 25, 'M', 'Comptabilité', 1400);
insert into employe values ( 80,'Amir', 'Amor', 'TUN', 55, 'M', 'Marketing', 1200);
3/
Exécution
4/
update employe
5/
update employe
6/
7/
8/
9/
10/
*) select Nationalite
from employe ;
11/
12/
select nom,prenom
from employe
13/
from employe
15/
select nom , prenom ,age from employe where nom like 'w???r' ;
16/
17/
select prenom ,nom from employe where nom not like 'T%';
18/
19/
select prenom,nom
20/
FROM Employe
21/
22/
(24,'adel','bouallem','Alg',,'M',,1000);
23/
24/
25/
select *from employe where (sexe='m' and (age between 20 and 30))
or (sexe='f' and (age between 40 and 50));//and est plus fort que or
26/
27/
28/
select * from employe where sexe='m' and age <45 and nationalite not in ('tun', 'ita', 'alg');
29/
select prenom , nom , salaire*0.20 as "commission" from employe ;// select prenom , nom ,
salaire*0.20 as commission from employe ;
30/
select nom , prenom , salaire from employe where sexe ='m' order by salaire desc ;
31/
select * from employe order by (nationalite) , (salaire) desc ;// tri nation apr salaire
32/
select avg(age)
34/select count(*)
35/
select count(distinct(nationalite))
from employe ;
36/
37/
from employe
group by (service)
39
from employe
group by (service) ;
40/
from employe
group by nationalite
having(count(*)>1);
41/
from employe
group by nationalite
having(count(*)>1);