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

Consultas

This document contains 4 SQL queries: 1) Counts the total sales and number of sales reps by country for reps hired over 1 year ago grouped by country and job. 2) Summarizes product sales quantities and maximum unit price by product name for products sold in the US grouped by product. 3) Lists product name, quantity on hand, and location concatenated from city and street for inventory grouped by product and location. 4) Calculates a percentile salary and average range by job title grouped by title and percentile.

Uploaded by

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

Consultas

This document contains 4 SQL queries: 1) Counts the total sales and number of sales reps by country for reps hired over 1 year ago grouped by country and job. 2) Summarizes product sales quantities and maximum unit price by product name for products sold in the US grouped by product. 3) Lists product name, quantity on hand, and location concatenated from city and street for inventory grouped by product and location. 4) Calculates a percentile salary and average range by job title grouped by title and percentile.

Uploaded by

Leo Mancia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 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