documenttp

2
INSERT INTO EMPLOYES VALUES (7839,'KING','PRESIDENT','1981-11-17',5000,1200,10), (7716,'BLAKE','MANAGER','1981-05-1',2850,800,30), (7782,'CLARK','MANAGER','1981-06-9',2450,800,10), (7566,'JONES','MANAGER','1981-04-2',2975,750,20), (7654,'MARTIN','SALESMAN','1981-09-28',1250,400,30), (7499,'ALLEN','SALESMAN','1981-02-20',1600,400,30), (7844,'TURNER','SALESMAN','1981-09-8',1500,500,30), (7900,'JAMES','CLERK','1981-12-3',950,300,30), (7521,'WARD','SALEMAN','1981-02-32',1250,400,30), (7902,'FORD','ANALYST','1981-12-3',3000,800,20), (7369,'SMITH','CLERK','1980-12-17',800,300,20), (7788,'SCOTT','ANALYST','1982-12-09',3000,800,20), (7829,'ADAMS','CLERK','1983-12-12',1100,400,20), (7615,'MILLER','CLERK','1982-01-23',1100,400,10); Select NE,nom from employes; Select *from employes Select NE,nom,job from employes; Select distinct nom from employes Select distinct ND,job from employes /*******Renomage de l'attribut/ Select nom as smiya from employes /******plus l'affichage de la somme de salary + benifits******/ Select NE,nom,salary,benifits,salary+benifits from employes; /********afichage de la longeur de nom**************/ Select NE,nom,length(nom) from employes /******selection de l'anneè d'embauche de chaque employee*////// Select NE,nom,year (`DATEMB`) from employes; /*****les salaires par tranches*****/ Select NE,nom, case when salary < 1000 then "petit" when salary < 2000 then "moy en" else "gros" end FROM EMPLOYES /*********************selection des employe nd=30 Select *from employes where ND=30; /////employer salarire 3000euro SELECT NE,nom from employes where salary=3000; /*****les salaire entre 1200 et 1400 SELECT NE,nom,salary from employes where salary between 1200 and 1400; ///*******selection de salaire sans redondances Select distinct salary from employes; /****selection SELECT distinct job from employes /*******le terme se trouve dans la liste SELECT NE,nom,ND from employes where ND in(10,30) AREVOISELECT NE,nom from employes where nom like '__A%'; /*****classement par ordre descendant ou asc Select job,salary,nom, NE from employes order by job asc,salary desc,nom; /******afficher que 5 ligne Select NE,nom,salary from employes limit 5 /affichage max Select NE,nom,salary from employes order by salary desc limit 1 /***le minimum Select NE,nom,salary from employes order by salary asc limit 1

Upload: imad-hakkache

Post on 08-Apr-2016

6 views

Category:

Documents


1 download

DESCRIPTION

tp3

TRANSCRIPT

Page 1: DocumentTP

INSERT INTO EMPLOYES VALUES (7839,'KING','PRESIDENT','1981-11-17',5000,1200,10),(7716,'BLAKE','MANAGER','1981-05-1',2850,800,30),(7782,'CLARK','MANAGER','1981-06-9',2450,800,10),(7566,'JONES','MANAGER','1981-04-2',2975,750,20),(7654,'MARTIN','SALESMAN','1981-09-28',1250,400,30),(7499,'ALLEN','SALESMAN','1981-02-20',1600,400,30),

(7844,'TURNER','SALESMAN','1981-09-8',1500,500,30),(7900,'JAMES','CLERK','1981-12-3',950,300,30),

(7521,'WARD','SALEMAN','1981-02-32',1250,400,30),

(7902,'FORD','ANALYST','1981-12-3',3000,800,20),(7369,'SMITH','CLERK','1980-12-17',800,300,20),

(7788,'SCOTT','ANALYST','1982-12-09',3000,800,20),(7829,'ADAMS','CLERK','1983-12-12',1100,400,20),(7615,'MILLER','CLERK','1982-01-23',1100,400,10);Select NE,nom from employes;Select *from employesSelect NE,nom,job from employes;Select distinct nom from employesSelect distinct ND,job from employes/*******Renomage de l'attribut/Select nom as smiya from employes/******plus l'affichage de la somme de salary + benifits******/Select NE,nom,salary,benifits,salary+benifits from employes;/********afichage de la longeur de nom**************/Select NE,nom,length(nom) from employes/******selection de l'anneè d'embauche de chaque employee*//////Select NE,nom,year (`DATEMB`) from employes;/*****les salaires par tranches*****/Select NE,nom, case when salary < 1000 then "petit" when salary < 2000 then "moyen" else "gros" end FROM EMPLOYES/*********************selection des employe nd=30Select *from employes where ND=30;/////employer salarire 3000euroSELECT NE,nom from employes where salary=3000;/*****les salaire entre 1200 et 1400SELECT NE,nom,salary from employes where salary between 1200 and 1400;///*******selection de salaire sans redondancesSelect distinct salary from employes;/****selectionSELECT distinct job from employes/*******le terme se trouve dans la listeSELECT NE,nom,ND from employes where ND in(10,30)

AREVOISELECT NE,nom from employes where nom like '__A%';/*****classement par ordre descendant ou ascSelect job,salary,nom, NE from employesorder by job asc,salary desc,nom;/******afficher que 5 ligneSelect NE,nom,salary from employes limit 5/affichage maxSelect NE,nom,salary from employes order by salary desc limit 1/***le minimumSelect NE,nom,salary from employes order by salary asc limit 1

Page 2: DocumentTP

/******recuperation des 10 suivantsSELECT job,salary,nom,NE from employes order by job asc,salary desc,nom limit 10,5;SELECT job,salary,nom,NE from employes order by job asc,salary desc,nom limit 5 offset 10;/****permet de compte nombre tuple no nullSelect count(NE) from employesSelect count(distinct job) from employes/***la moyenSelect avg(salary) from employes;Select sum(salary) from employesSelect min(salary) from employesSelect max(salary) from employesSelect max(salary),min(salary) from employes/*******groupoementSelect job,count(*),avg(salary) from employes group by job;Select ND,max(salary) from employes group by ND;/****having nb conditionSelect job,count(*) from employesgroup by jobhaving count(*)>=3///*********HAVIBNG + TRISelect job,count(*) nb from employesgroup by jobhaving count(*)>=3order by nb desc/*****renomage + utilisation dans le havinSelect job,count(*) nb from employesgroup by jobhaving nb>2order by nb desc/*****produit cartesieSelect from * employes,dept;sELECT * FROM employes,deptwhere employes.ND=dept.NDSelect * from employes where job='CLERK'sELECT * FROM employes,dept where employes.ND=dept.ND and SALARY=3000