Use Atlantic;
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'usp_Count_Inventory') AND type = 'P')
DROP PROCEDURE dbo.usp_Count_Inventory
GO
Use Atlantic;
GO
CREATE PROCEDURE usp_Count_Inventory @min_category INT, @max_category INT
AS
SELECT C.category_id
, C.category_name
, COUNT(*) AS category_inventory
FROM Product AS P INNER JOIN Category AS C
	on P.category_id = C.category_id
WHERE C.category_id BETWEEN @min_category AND @max_category
GROUP BY C.category_id, C.category_name
ORDER BY C.category_id
--GO
--EXEC usp_count_inventory 2, 5
