SQL 5
SQL 5
SQL 5
1-
Verdadero
2-
Falso
3-
Verdadero
4-
5-
SELECTjob_id,
ROUND(MAX(salary),0) "Maximum",
ROUND(MIN(salary),0) "Minimum",
ROUND(SUM(salary),0) "Sum",
ROUND(AVG(salary),0) "Average"
FROM employees
GROUP BY job_id;
6-
SELECTjob_id, COUNT(*)
FROM employees
GROUP BY job_id;
7-
8-
SELECTMAX(salary) - MIN(salary)
DIFFERENCE FROM employees;
9-
SELECTmanager_id, MIN(salary)
FROM employees
WHERE manager_id IS NOT NULL
GROUP BY manager_id
HAVING MIN(salary) > 6000
ORDER BY MIN(salary) DESC;
10-
11-
SELECTCOUNT(*) total,
SUM(DECODE(TO_CHAR(hire_date, 'YYYY'),1995,1,0))"1 995",
SUM(DECODE(TO_CHAR(hire_date,'YYYY'),1996,1,0))"1 996",
SUM(DECODE(TO_CHAR(hire_date,'YYYY'),1997,1,0))"1 997",
SUM(DECODE(TO_CHAR(hire_date,'YYYY'),1998,1,0))"1 998"
FROM employees;
12-
SELECTjob_id "Job",
SUM(DECODE(department_id , 20, salary)) "Dept 20" ,
SUM(DECODE(department_id , 50, salary)) "Dept 50" ,
SUM(DECODE(department_id , 80, salary)) "Dept 80" ,
SUM(DECODE(department_id , 90, salary)) "Dept 90" , SUM(salary)
"Total"
FROM employees
GROUP BY job_id;
EJERCICIOS ADICIONALES TEMA 5 ORACLE
SELECT max(comisión_pct),max(last_name),max(hire_date)
FROM employees;
SELECT max(comisión_pct),max(last_name),max(hire_date)
FROM employees
WHERE department_id=50;
SELECT max(comisión_pct),max(last_name),max(hire_date)
FROM employees
GROUP BY department_id=50
HAVING department_id=50
8. Idem pero mostrANDo también los departamentos sin jefe. En este caso que
diga ‘Sin jefe’ en lugar del apellido.
3. Ídem del 2 però només de les ciutats que pertanyin als ‘United States of America’.
4. Contar quants empleats cobren el matexi salari dintre de cada departament (nom).
SELECT count(employee_id)
FROM job_history
WHERE start_date like ‘%/%/87’;
4. Listar para cada last_name de jefe, el salario medio de los empleados que
dependen de él.