Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 2

PARTE 3 Consulta 1

SELECT cc.country_name AS Paises, SUM(ord.order_total) AS Total

COUNT(DISTINCT emp.employee_id) AS Vendedores FROM oe.orders ord

JOIN hr.employees emp ON ord.sales_rep_id = emp.employee_id

JOIN hr.jobs job ON emp.job_id = job.job_id

JOIN hr.departments dep ON emp.department_id =dep.department_id

JOIN hr.locations loca ON dep.location_id = loca.location_id

JOIN hr.countries cc ON loca.country_id =cc.country_id

WHERE ((sydate -emp.hire_date)/365)>1

GROUP BY cc.country_name, job.job_id

HAVING job.job_id= 'SA_REP'

PARTE 3 Consulta 2

SELECT pi.product_name AS Nombre, SUM(oi.quantity) AS Ventas, MAX(oi.unit_price) AS


Precio_Maximo

FROM oe.product information pi

JOIN oe.order_items oi ON pi.product_id = oi.product_id

JOIN oe.orders od ON oi.order id = od.order_id

JOIN oe.inventories inv ON pi.product_id = inv.product_id

JOIN oe.warehouses wa ON inv.warehouse_id = wa.warehouse_id

JOIN hr.locations loc ON wa.location_id = loc. location_id

JOIN hr.countries cc ON loc.country_id = cc.country_id

WHERE cc.country_id 'US'

GROUP BY pi.product_id, pi.product_name


PARTE 3 Consulta 3

SELECT pi.product_name AS Productos, inv.quantity_on_hand AS Disponibles,

CONCAT (loca.city, CONCAT (' ',loca.street_address)) AS Ubicación FROM oe.inventories inv

JOIN oe.product information pi ON inv.product_id=pi.product_id

JOIN oe.warehouses wa ON wa.warehouse_id=inv.warehouse_id

JOIN hr.locations loca ON local.location id=wa.location id

PARTE 3 Consulta 4

SELECT job_title AS trabajo, (max_salary*min_salary/100) AS Percentil

AVG (max salary min salary) AS promedio FROM hr.jobs

GROUP BY job_title, (max_salary*min_salary/100)

You might also like