0% found this document useful (0 votes)
7 views2 pages

Practica

The document contains SQL queries for various employee-related data analyses. It includes counting employees by region, finding employees with the same last name, identifying the highest-paid employees in each department, calculating average salaries by country with employee counts, and showing employee job history with duration calculations. Each query is structured to retrieve specific insights from a database involving employees, departments, locations, countries, and regions.

Uploaded by

carlos.sotomayor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Practica

The document contains SQL queries for various employee-related data analyses. It includes counting employees by region, finding employees with the same last name, identifying the highest-paid employees in each department, calculating average salaries by country with employee counts, and showing employee job history with duration calculations. Each query is structured to retrieve specific insights from a database involving employees, departments, locations, countries, and regions.

Uploaded by

carlos.sotomayor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

NOMBRES:

FLORES MAMANI CHRISTIAN SEBASTIAN

FLORES VALENCIA GONSALO

1.-Mostrar la cantidad de empleados por región


select count(*) as Cantidad_Por_departamento,region_name

from employees e,

departments d,

locations l, countries c ,

regions r

where

e.department_id = d.department_id and

d.location_id = l.location_id and

l.country_id = c.country_id and

c.region_id = r.region_id group by region_name;

2.- Mostrar los empleados que tienen el mismo apellido select e.First_name ||' '||e.Last_name as

Nombre_primer_empleado ,

f.First_name ||' '||f.last_name as Nombre_segundo_empleado from employees e, employees f where


f.last_name = e.last_name and e.Employee_id != f.Employee_id;

3.- Mostrar a los empleados mejor pagados en cada departamento

select e.First_name ,max(salary) over (partition by d.department_id) as salario_maximo,


d.department_name from employees e, departments d where e.department_id =
d.department_id;
4.-Calcular el promedio de los salarios por país mostrando a que región pertenece junto con el numero de empleados

select

DISTINCT count(e.employee_id) over (partition by c.country_name) as Cantidad_de_empleados, c.country_name,

round(avg(salary) over (partition by c.country_name),2) as promedio_de_salario_por_pais, r.region_name

from employees e,

departments d,

locations l, countries

c , regions r where

e.department_id = d.department_id and

d.location_id = l.location_id and

l.country_id = c.country_id and

c.region_id = r.region_id ORDER BY CANTIDAD_DE_EMPLEADOS

5.- mostrar el historial de trabajos de los empleados calculando la duración de días de dichos trabajos select e.first_name, j.* ,
(j.end_date - j.start_date) as duracion_dias, jb.job_title from employees e, job_history j, jobs jb where e.employee_id =
j.employee_id and jb.job_id = j.job_id;

You might also like