Advertisement
Guest User

13,14,15 oracle

a guest
Sep 28th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1.  
  2. 13. Volem saber quants empleats treballen a cada departament. Mostra de cada departament, el número d'empleats i el nom de departament.
  3.  
  4. SELECT COUNT(e.employee_id) as NUMERO_TREBALLADORS,d.department_name,d.department_id
  5. FROM EMPLOYEES e, DEPARTMENTS d
  6. WHERE e.department_id = d.department_id
  7. GROUP BY d.DEPARTMENT_NAME, d.department_id;
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. 14. Partint de la consulta anterior, mostra només els departaments que tenen assignats més de 30 empleats. Ordena la informació segons el número d'empleats.
  15.  
  16. SELECT COUNT(e.employee_id) as NUMERO_TREBALLADORS,d.department_name,d.department_id
  17. FROM EMPLOYEES e, DEPARTMENTS d
  18. WHERE e.department_id = d.department_id
  19. GROUP BY d.DEPARTMENT_NAME, d.department_id
  20. HAVING COUNT(e.employee_id) > 30;
  21.  
  22. 15. Mostra els empleats que tenen un sou superior a la mitjana del departament de Vendes (Sales). Volem saber el nom, cognom, salari i nom de departament.
  23.  
  24. SELECT e.FIRST_NAME, e.LAST_NAME, e.SALARY, d.DEPARTMENT_NAME
  25. FROM EMPLOYEES e, DEPARTMENTS d
  26. WHERE e.DEPARTMENT_ID = d.DEPARTMENT_ID AND salary >
  27.  
  28. (SELECT AVG(e.SALARY)
  29. FROM EMPLOYEES e, DEPARTMENTS d
  30. where e.DEPARTMENT_ID = d.DEPARTMENT_ID AND d.department_name = 'Sales');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement