De la Base de datos NorthWind elaboraremos las siguientes consultas:
Ejercicio 1:
Select C.CategoryName,C.CategoryID, COUNT(P.ProductID) 'CANTIDAD DE PRODUCTOS'
from Products P JOIN Categories C ON (C.CategoryID = P.CategoryID)
group by C.CategoryName,C.CategoryID
having COUNT(P.ProductID) >= 4
Order by 3
Ejercicio 2:
select E.FirstName,E.EmployeeID, COUNT(E.EmployeeID)'Cantidad Sub-alternos'
from Employees E JOIN Employees E2 ON (E.EmployeeID = E2.ReportsTo)
group by E.FirstName,E.EmployeeID
having COUNT(E.EmployeeID)>1


No hay comentarios:
Publicar un comentario