Mostrando entradas con la etiqueta hr. Mostrar todas las entradas
Mostrando entradas con la etiqueta hr. Mostrar todas las entradas

domingo, 24 de mayo de 2009

Práctica con el esquema HR de oracle 10g

Para quienes les a costado encontrar el esquema HR de oracle 10g aquí esta.

Lo siguiente es una pequeña práctica para quienes no se acuerdan mucho de los select en sql.

Próximamente les muestro cuales serían las salidas de los select.

__________________________


Seleccionar first_name, last_name, department_name.
select first_name, last_name, department_name from hr.employees e join hr.departments d on e.department_id = d.department_id

Seleccionar la cantidad de empleados por departamento.
select count(employee_id),department_name from hr.employees e join hr.departments d on e.department_id = d.department_id group by (d.department_name)

Cantidad de empleados por ciudad.
select count(employee_id),city from (hr.employees e join hr.departments d on e.department_id = d.department_id) join hr.locations l on d.location_id = l.location_id group by (l.city)

Cantidad de departamentos por país.
select count(department_id),country_name from (hr.departments d join hr.locations l on d.location_id = l.location_id) join hr.countries c on l.country_id = c.country_id group by (c.country_name)

Muestra la cantidad de empleados por región

select count(employee_id),region_name from(((hr.employees e join hr.departments d on e.department_id = d.department_id)join hr.locations l on d.location_id = l.location_id)joinhr.countries c on l.country_id = c.country_id) joinhr.regions r on c.region_id = r.region_id group by (r.region_name) Muestra la cantidad de empleados por país select count(employee_id),country_name from(((hr.employees e join hr.departments d on e.department_id = d.department_id)join hr.locations l on d.location_id = l.location_id)joinhr.countries c on l.country_id = c.country_id) joinhr.regions r on c.region_id = r.region_id group by (c.country_name)

Cantidad de empleados por país y por región
select region_name,country_name,count(employee_id)from
(((hr.employees e join hr.departments d on e.department_id = d.department_id)join
hr.locations l on d.location_id = l.location_id)join
hr.countries c on l.country_id = c.country_id) join
hr.regions r on c.region_id = r.region_id group by (c.country_name,r.region_name)

Cualquier consulta adicional, con mucho gusto....

_________________________________

M46R4B0...