select department_id as "Departamento",
count(*) as "Total Empleado"
From employees
group by department_id
select DEPARTMENT_NAME as "departamento",
count(*) as "totalEmpleados"
from DEPARTMENTS d, EMPLOYEES e
Where e.DEPARTMENT_ID = d.DEPARTMENT_ID
Group by DEPARTMENT_NAME
Seleccionar el nombre de los departamentos donde trabaja el empleado.
select DEPARTMENT_NAME ,count(EMPLOYEE_ID)
from DEPARTMENTS d, EMPLOYEES e
Where e.DEPARTMENT_ID = d.DEPARTMENT_ID
Group by DEPARTMENT_NAME
Order by DEPARTMENT_NAME
---------------------------------------------
Cursor
Declare
cursor miCursor is
select department_id ,
count(*)
From employees
group by department_id
Order by department_id;
vDepartamento employeeS.employee_id%type;
vTotEmpleado integer;
Begin
open miCursor;
dbms_output.put_line('Departamento TotEmpleado');
loop
fetch miCursor into vDepartamento, vTotEmpleado;
exit when miCursor%notfound;
dbms_output.put_line(vDepartamento || ' ' || vTotEmpleado);
end loop;
close miCursor;
End;
----------------------------------------------
Saber cual es el nombre de un codigo de un depto.
Declare
vNumeroDepto integer := 10;
vNombreDepto char(50);
begin
Select DEPARTMENT_NAME into vNombreDepto
from departments
where department_id = vNumeroDepto;
dbms_output.put_line('El codigo del depto es : ' || vNumeroDepto);
dbms_output.put_line('El codigo del depto es : ' || vNombreDepto);
end;
No hay comentarios.:
Publicar un comentario