SlideShare a Scribd company logo
1 of 14
Download to read offline
Taller SQL Oracle Live - Resultados
SELECT TO_CHAR(ROUND(MAX(salary)), '$99,999.00') AS "Salario Máximo",
TO_CHAR(ROUND(MIN(salary)), '$99,999.00') AS "Salario Mínimo",
TO_CHAR(ROUND(SUM(salary)), '$999,999.00') AS "Salario Planilla",
TO_CHAR(ROUND(AVG(salary)), '$99,999.00') AS "Salario Promedio"
FROM hr.employees;
SELECT j.job_title AS "Puesto",
TO_CHAR(ROUND(MAX(e.salary), 2), '$99,999.00') AS "Salario Máximo",
TO_CHAR(ROUND(MIN(e.salary), 2), '$99,999.00') AS "Salario Mínimo",
TO_CHAR(ROUND(SUM(e.salary), 2), '$999,999.00') AS "Salario Total",
TO_CHAR(ROUND(AVG(e.salary), 2), '$99,999.00') AS "Salario Promedio"
FROM hr.employees e
INNER JOIN hr.jobs j ON e.job_id=j.job_id
GROUP BY j.job_title;
SELECT j.job_title AS "Puesto",
COUNT(e.job_id) AS "Total Empleados",
TO_CHAR(ROUND(SUM(e.salary), 2), '$999,999.00') AS "Salario Total"
FROM hr.employees e
INNER JOIN hr.jobs j ON e.job_id=j.job_id
GROUP BY j.job_title
ORDER BY 2 DESC
SELECT TO_CHAR(ROUND(MAX(salary), 2), '$99,999.00') AS "Salario Máximo",
TO_CHAR(ROUND(MIN(salary), 2), '$99,999.00') AS "Salario Mínimo",
TO_CHAR(ROUND(MAX(salary) - MIN(salary), 2), '$99,999.00') AS "Diferencia Salarial"
FROM hr.employees
SELECT DISTINCT(m.manager_id) "Manager",
(-- INICIO SUBQUERY
SELECT TO_CHAR(ROUND(e.salary, 2), '$99,999.00')
FROM hr.employees e
WHERE e.manager_id=m.manager_id
ORDER BY e.salary ASC FETCH NEXT 1 ROWS ONLY -- FIN SUBQUERY
) AS "Salario Mínimo de Empleado"
FROM hr.employees m
INNER JOIN hr.jobs j ON m.job_id=j.job_id
WHERE m.manager_id>0
AND j.min_salary>=6000
ORDER BY 2 DESC
SELECT manager_id "Manager",min(salary)
FROM hr.employees
WHERE manager_id IS NOT NULL
AND job_id NOT IN
(SELECT job_id
FROM employees
GROUP BY job_id
HAVING MIN(salary) <6000)
GROUP BY manager_id
ORDER BY 2 DESC
SELECT (first_name || ' ' || last_name) "Nombres Empleado",
d.department_name "Departamento",
j.job_title "Puesto"
FROM hr.employees e
INNER JOIN hr.departments d ON e.department_id=d.department_id
INNER JOIN hr.jobs j ON e.job_id=j.job_id
WHERE d.location_id=1700
ORDER BY e.last_name ASC
SELECT (m.first_name || ' ' || m.last_name) "Manager",
j.job_title "Puesto",
d.department_name "Departamento",
TO_CHAR(ROUND(m.salary, 2), '$999,999.00') "Salario",
(SELECT COUNT(employee_id)
FROM hr.employees
WHERE manager_id = m.employee_id) "Total Empleados"
FROM hr.employees m
INNER JOIN hr.jobs j ON m.job_id=j.job_id
INNER JOIN hr.departments d ON m.department_id=d.department_id
WHERE m.employee_id IN
(SELECT DISTINCT(manager_id)
FROM hr.employees)
ORDER BY 5 DESC
SELECT (e.first_name || ' ' || e.last_name) "Empleado",
COUNT(jh.employee_id) "Rotaciones"
FROM hr.job_history jh
INNER JOIN hr.employees e ON jh.employee_id=e.employee_
id
GROUP BY (e.first_name || ' ' || e.last_name)
HAVING COUNT(jh.employee_id)>1
SELECT TO_CHAR(hire_date, 'YYYY') "Año Contratación",
COUNT(employee_id) "Empleados"
FROM hr.employees
GROUP BY TO_CHAR(hire_date, 'YYYY')
ORDER BY 2 DESC
SELECT (e.first_name || ' ' || e.last_name) "Empleado",
TO_CHAR(ROUND(e.salary, 2), '$99,999.00') "Salario Actual",
TO_CHAR(ROUND(j.min_salary, 2), '$99,999.00') "Salario Mínimo Puesto",
TO_CHAR(ROUND(j.max_salary, 2), '$99,999.00') "Salario Máximo Puesto",
TO_CHAR(ROUND((e.salary + e.salary*0.08),2), '$99,999.00') "Nuevo Salario"
FROM hr.employees e
INNER JOIN hr.jobs j ON e.job_id=j.job_id
WHERE e.salary<=j.min_salary
OR e.salary BETWEEN j.min_salary AND (j.min_salary+j.min_salary*0.05)
SELECT EXTRACT(YEAR
FROM hire_date) "Año",
COUNT(employee_id) "Empleados que ingresaron",
TO_CHAR(ROUND(SUM(salary), 2), '$999,999.00') "Planilla Mensual",
TO_CHAR(ROUND(SUM(salary)*12, 2), '$9,999,999.00') "Planilla Anual",
TO_CHAR(ROUND(AVG(salary), 2), '$99,999.00') "Salario Promedio Mensual"
FROM hr.employees
GROUP BY EXTRACT(YEAR
FROM hire_date)
ORDER BY 1 ASC
SELECT (first_name || ' ' || last_name) "Empleado",
hire_date "Fecha Ingreso",
TO_CHAR(ROUND(salary, 2), '$99,999.00') "Salario Actual",
TO_CHAR(ROUND((salary + salary*0.2),2), '$99,999.00') "Nuevo Salario"
FROM hr.employees
WHERE extract(YEAR
FROM hire_date) BETWEEN 2003 AND 2005
ORDER BY 3 DESC;
SELECT TO_CHAR(ROUND(AVG(e.salary)), '$999,999.00') AS "Salario Promedio Stock Manager
"
FROM hr.employees e
JOIN hr.jobs j ON e.job_id = j.job_id
WHERE j.job_title = 'Stock Manager';

More Related Content

Similar to Solucionario de Ejercicios de PL/SQL.pdf

Database Query Using SQL_ip.docx
Database Query Using SQL_ip.docxDatabase Query Using SQL_ip.docx
Database Query Using SQL_ip.docxVandanaGoyal21
 
sql ppt for students who preparing for sql
sql ppt for students who preparing for sqlsql ppt for students who preparing for sql
sql ppt for students who preparing for sqlbharatjanadharwarud
 
Apurv Gupta, BCA ,Final year , Dezyne E'cole College
 Apurv Gupta, BCA ,Final year , Dezyne E'cole College Apurv Gupta, BCA ,Final year , Dezyne E'cole College
Apurv Gupta, BCA ,Final year , Dezyne E'cole Collegedezyneecole
 
Query all roles and duties and privileges Oracle Fusion Cloud
Query all roles and duties and privileges Oracle Fusion CloudQuery all roles and duties and privileges Oracle Fusion Cloud
Query all roles and duties and privileges Oracle Fusion CloudFeras Ahmad
 
NumPy_Aggregations - Python for Data Science.pptx
NumPy_Aggregations - Python for Data Science.pptxNumPy_Aggregations - Python for Data Science.pptx
NumPy_Aggregations - Python for Data Science.pptxJohnWilliam111370
 
Implementation Specifications
Implementation SpecificationsImplementation Specifications
Implementation SpecificationsUnmon Mukherjee
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functionssinhacp
 
Mongo db world 2014 billrun
Mongo db world 2014   billrunMongo db world 2014   billrun
Mongo db world 2014 billrunMongoDB
 
Week 03 Lesson 02 recursive data definitions everywhere
Week 03 Lesson 02 recursive data definitions everywhereWeek 03 Lesson 02 recursive data definitions everywhere
Week 03 Lesson 02 recursive data definitions everywhereMitchell Wand
 
Aggregate Function - Database
Aggregate Function - DatabaseAggregate Function - Database
Aggregate Function - DatabaseShahadat153031
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricksYanli Liu
 

Similar to Solucionario de Ejercicios de PL/SQL.pdf (20)

Database Query Using SQL_ip.docx
Database Query Using SQL_ip.docxDatabase Query Using SQL_ip.docx
Database Query Using SQL_ip.docx
 
KScope19 - SQL Features
KScope19 - SQL FeaturesKScope19 - SQL Features
KScope19 - SQL Features
 
Clauses
ClausesClauses
Clauses
 
sql ppt for students who preparing for sql
sql ppt for students who preparing for sqlsql ppt for students who preparing for sql
sql ppt for students who preparing for sql
 
Les03
Les03Les03
Les03
 
PL_PKG_TASK
PL_PKG_TASKPL_PKG_TASK
PL_PKG_TASK
 
Apurv Gupta, BCA ,Final year , Dezyne E'cole College
 Apurv Gupta, BCA ,Final year , Dezyne E'cole College Apurv Gupta, BCA ,Final year , Dezyne E'cole College
Apurv Gupta, BCA ,Final year , Dezyne E'cole College
 
Sub queries
Sub queriesSub queries
Sub queries
 
Query all roles and duties and privileges Oracle Fusion Cloud
Query all roles and duties and privileges Oracle Fusion CloudQuery all roles and duties and privileges Oracle Fusion Cloud
Query all roles and duties and privileges Oracle Fusion Cloud
 
Programação funcional em Python
Programação funcional em PythonProgramação funcional em Python
Programação funcional em Python
 
NumPy_Aggregations - Python for Data Science.pptx
NumPy_Aggregations - Python for Data Science.pptxNumPy_Aggregations - Python for Data Science.pptx
NumPy_Aggregations - Python for Data Science.pptx
 
Implementation Specifications
Implementation SpecificationsImplementation Specifications
Implementation Specifications
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
 
Mongo db world 2014 billrun
Mongo db world 2014   billrunMongo db world 2014   billrun
Mongo db world 2014 billrun
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Week 03 Lesson 02 recursive data definitions everywhere
Week 03 Lesson 02 recursive data definitions everywhereWeek 03 Lesson 02 recursive data definitions everywhere
Week 03 Lesson 02 recursive data definitions everywhere
 
Ravi querys 425
Ravi querys  425Ravi querys  425
Ravi querys 425
 
Aggregate Function - Database
Aggregate Function - DatabaseAggregate Function - Database
Aggregate Function - Database
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
 
Php functions
Php functionsPhp functions
Php functions
 

More from Pedro Narváez

Practica DE PL/SQL 1.pdf
Practica DE PL/SQL 1.pdfPractica DE PL/SQL 1.pdf
Practica DE PL/SQL 1.pdfPedro Narváez
 
David Noel Ramirez Padilla .pdf
David Noel Ramirez Padilla .pdfDavid Noel Ramirez Padilla .pdf
David Noel Ramirez Padilla .pdfPedro Narváez
 
UNIDAD 2 INTRODUCCIÓN A LA ADMINISTRACIÓN Y A LAS ORGANIZACIONES.ppsx
UNIDAD 2 INTRODUCCIÓN A LA ADMINISTRACIÓN Y A LAS ORGANIZACIONES.ppsxUNIDAD 2 INTRODUCCIÓN A LA ADMINISTRACIÓN Y A LAS ORGANIZACIONES.ppsx
UNIDAD 2 INTRODUCCIÓN A LA ADMINISTRACIÓN Y A LAS ORGANIZACIONES.ppsxPedro Narváez
 
Manual de-Bobinagem-weg
Manual de-Bobinagem-wegManual de-Bobinagem-weg
Manual de-Bobinagem-wegPedro Narváez
 
Ajedrez curso-completo-no-1-garry-kasparov
Ajedrez curso-completo-no-1-garry-kasparovAjedrez curso-completo-no-1-garry-kasparov
Ajedrez curso-completo-no-1-garry-kasparovPedro Narváez
 

More from Pedro Narváez (8)

5_Armonicos.pdf
5_Armonicos.pdf5_Armonicos.pdf
5_Armonicos.pdf
 
Practica DE PL/SQL 1.pdf
Practica DE PL/SQL 1.pdfPractica DE PL/SQL 1.pdf
Practica DE PL/SQL 1.pdf
 
P1_SQL_Repaso.pdf
P1_SQL_Repaso.pdfP1_SQL_Repaso.pdf
P1_SQL_Repaso.pdf
 
David Noel Ramirez Padilla .pdf
David Noel Ramirez Padilla .pdfDavid Noel Ramirez Padilla .pdf
David Noel Ramirez Padilla .pdf
 
UNIDAD 2 INTRODUCCIÓN A LA ADMINISTRACIÓN Y A LAS ORGANIZACIONES.ppsx
UNIDAD 2 INTRODUCCIÓN A LA ADMINISTRACIÓN Y A LAS ORGANIZACIONES.ppsxUNIDAD 2 INTRODUCCIÓN A LA ADMINISTRACIÓN Y A LAS ORGANIZACIONES.ppsx
UNIDAD 2 INTRODUCCIÓN A LA ADMINISTRACIÓN Y A LAS ORGANIZACIONES.ppsx
 
Manual
ManualManual
Manual
 
Manual de-Bobinagem-weg
Manual de-Bobinagem-wegManual de-Bobinagem-weg
Manual de-Bobinagem-weg
 
Ajedrez curso-completo-no-1-garry-kasparov
Ajedrez curso-completo-no-1-garry-kasparovAjedrez curso-completo-no-1-garry-kasparov
Ajedrez curso-completo-no-1-garry-kasparov
 

Recently uploaded

CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Recently uploaded (20)

CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

Solucionario de Ejercicios de PL/SQL.pdf

  • 1. Taller SQL Oracle Live - Resultados SELECT TO_CHAR(ROUND(MAX(salary)), '$99,999.00') AS "Salario Máximo", TO_CHAR(ROUND(MIN(salary)), '$99,999.00') AS "Salario Mínimo", TO_CHAR(ROUND(SUM(salary)), '$999,999.00') AS "Salario Planilla", TO_CHAR(ROUND(AVG(salary)), '$99,999.00') AS "Salario Promedio" FROM hr.employees;
  • 2. SELECT j.job_title AS "Puesto", TO_CHAR(ROUND(MAX(e.salary), 2), '$99,999.00') AS "Salario Máximo", TO_CHAR(ROUND(MIN(e.salary), 2), '$99,999.00') AS "Salario Mínimo", TO_CHAR(ROUND(SUM(e.salary), 2), '$999,999.00') AS "Salario Total", TO_CHAR(ROUND(AVG(e.salary), 2), '$99,999.00') AS "Salario Promedio" FROM hr.employees e INNER JOIN hr.jobs j ON e.job_id=j.job_id GROUP BY j.job_title;
  • 3. SELECT j.job_title AS "Puesto", COUNT(e.job_id) AS "Total Empleados", TO_CHAR(ROUND(SUM(e.salary), 2), '$999,999.00') AS "Salario Total" FROM hr.employees e INNER JOIN hr.jobs j ON e.job_id=j.job_id GROUP BY j.job_title ORDER BY 2 DESC
  • 4. SELECT TO_CHAR(ROUND(MAX(salary), 2), '$99,999.00') AS "Salario Máximo", TO_CHAR(ROUND(MIN(salary), 2), '$99,999.00') AS "Salario Mínimo", TO_CHAR(ROUND(MAX(salary) - MIN(salary), 2), '$99,999.00') AS "Diferencia Salarial" FROM hr.employees
  • 5. SELECT DISTINCT(m.manager_id) "Manager", (-- INICIO SUBQUERY SELECT TO_CHAR(ROUND(e.salary, 2), '$99,999.00') FROM hr.employees e WHERE e.manager_id=m.manager_id ORDER BY e.salary ASC FETCH NEXT 1 ROWS ONLY -- FIN SUBQUERY ) AS "Salario Mínimo de Empleado" FROM hr.employees m INNER JOIN hr.jobs j ON m.job_id=j.job_id WHERE m.manager_id>0 AND j.min_salary>=6000 ORDER BY 2 DESC SELECT manager_id "Manager",min(salary) FROM hr.employees WHERE manager_id IS NOT NULL AND job_id NOT IN (SELECT job_id FROM employees GROUP BY job_id HAVING MIN(salary) <6000) GROUP BY manager_id ORDER BY 2 DESC
  • 6.
  • 7. SELECT (first_name || ' ' || last_name) "Nombres Empleado", d.department_name "Departamento", j.job_title "Puesto" FROM hr.employees e INNER JOIN hr.departments d ON e.department_id=d.department_id INNER JOIN hr.jobs j ON e.job_id=j.job_id WHERE d.location_id=1700 ORDER BY e.last_name ASC
  • 8. SELECT (m.first_name || ' ' || m.last_name) "Manager", j.job_title "Puesto", d.department_name "Departamento", TO_CHAR(ROUND(m.salary, 2), '$999,999.00') "Salario", (SELECT COUNT(employee_id) FROM hr.employees WHERE manager_id = m.employee_id) "Total Empleados" FROM hr.employees m INNER JOIN hr.jobs j ON m.job_id=j.job_id INNER JOIN hr.departments d ON m.department_id=d.department_id WHERE m.employee_id IN (SELECT DISTINCT(manager_id) FROM hr.employees) ORDER BY 5 DESC
  • 9. SELECT (e.first_name || ' ' || e.last_name) "Empleado", COUNT(jh.employee_id) "Rotaciones" FROM hr.job_history jh INNER JOIN hr.employees e ON jh.employee_id=e.employee_ id GROUP BY (e.first_name || ' ' || e.last_name) HAVING COUNT(jh.employee_id)>1
  • 10. SELECT TO_CHAR(hire_date, 'YYYY') "Año Contratación", COUNT(employee_id) "Empleados" FROM hr.employees GROUP BY TO_CHAR(hire_date, 'YYYY') ORDER BY 2 DESC
  • 11. SELECT (e.first_name || ' ' || e.last_name) "Empleado", TO_CHAR(ROUND(e.salary, 2), '$99,999.00') "Salario Actual", TO_CHAR(ROUND(j.min_salary, 2), '$99,999.00') "Salario Mínimo Puesto", TO_CHAR(ROUND(j.max_salary, 2), '$99,999.00') "Salario Máximo Puesto", TO_CHAR(ROUND((e.salary + e.salary*0.08),2), '$99,999.00') "Nuevo Salario" FROM hr.employees e INNER JOIN hr.jobs j ON e.job_id=j.job_id WHERE e.salary<=j.min_salary OR e.salary BETWEEN j.min_salary AND (j.min_salary+j.min_salary*0.05)
  • 12. SELECT EXTRACT(YEAR FROM hire_date) "Año", COUNT(employee_id) "Empleados que ingresaron", TO_CHAR(ROUND(SUM(salary), 2), '$999,999.00') "Planilla Mensual", TO_CHAR(ROUND(SUM(salary)*12, 2), '$9,999,999.00') "Planilla Anual", TO_CHAR(ROUND(AVG(salary), 2), '$99,999.00') "Salario Promedio Mensual" FROM hr.employees GROUP BY EXTRACT(YEAR FROM hire_date) ORDER BY 1 ASC
  • 13. SELECT (first_name || ' ' || last_name) "Empleado", hire_date "Fecha Ingreso", TO_CHAR(ROUND(salary, 2), '$99,999.00') "Salario Actual", TO_CHAR(ROUND((salary + salary*0.2),2), '$99,999.00') "Nuevo Salario" FROM hr.employees WHERE extract(YEAR FROM hire_date) BETWEEN 2003 AND 2005 ORDER BY 3 DESC;
  • 14. SELECT TO_CHAR(ROUND(AVG(e.salary)), '$999,999.00') AS "Salario Promedio Stock Manager " FROM hr.employees e JOIN hr.jobs j ON e.job_id = j.job_id WHERE j.job_title = 'Stock Manager';