-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGuia 4.sql
34 lines (29 loc) · 1.24 KB
/
Guia 4.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--Guía 4
select * from employees;
--Ejercicio 1 (Me salío mal hartas veces por que no lei el PPT - Que paja)
--Forma (A)
select employee_id "Identificación del empleado" , first_name ||' '||last_name "Empleado" , job_id "Job Id",to_char(salary,'$999G999') "Salario"
from employees
where salary = (select salary
from employees
where employee_id=204);
--Forma (B) (El calculo es muy paja)
select employee_id "Empleado",to_char(salary,'999G999') "Salario Actual",to_char(hire_date,'DD/MM/YYYY') "Fecha Contrato",
round(SYSDATE-hire_date) "Dias trabajados",
round(((SYSDATE-hire_date)/365)*12) "Meses trabajados",
round((SYSDATE-hire_date)/365) "Años trabajados"
from employees
where salary < (select round(avg(salary)) "Sueldo Promedio Redondeado"
from employees)
order by salary,employee_id;
--Forma (C)
select * from employees;
select * from departments;
select d.department_name "Nombre Departamento", COUNT(e.employee_id) "Cantidad maxima de Empleados"
from departments d join employees e
on(d.department_id = e.department_id)
group by d.department_name
having count(e.department_id) = (select max(COUNT(e.employee_id)) "Cantidad maxima de Empleados"
from departments d join employees e
on(d.department_id = e.department_id)
group by d. department_id);