You are on page 1of 1

--Mostrar los departamentos que tienes empleados.

create procedure sp_EmpledosDepartamento


as
begin
select d.Name
from HumanResources.Department d
where (select count(e.DepartmentID) from
HumanResources.EmployeeDepartmentHistory e
where e.DepartmentID= d.DepartmentID)>10
order by d.Name
end
go
execute sp_EmpledosDepartamento
go
--mostrar los empleados que tienen cantidad de empleados mayor a 10.
alter procedure sp_empleadoDepartamento
as
SELECT d.Name FROM HumanResources.Department d
WHERE (SELECT COUNT(e.DepartmentID) FROM
HumanResources.EmployeeDepartmentHistory e
WHERE e.DepartmentID=d.DepartmentID)>10
order by d.Name
go
execute sp_empleadoDepartamento
go
--mostrar, si se supone que cada vendedor solo cubre un territorio de
ventas
--los cliente del territorio que cubre linda mitchell.
create procedure sp_ClientesVendedor
as
begin
SELECT CustomerID FROM Sales.Customer C
WHERE C.TerritoryID=(SELECT S.TerritoryID FROM Sales.SalesPerson S
WHERE S.BusinessEntityID=276)
order by CustomerID
end
go
execute sp_ClientesVendedor
go

You might also like