on the example below the code am i suppose to creat it as procedure, i have to remove the insert because i have the datas in table as i showed you.
DECLARE @Inches AS TABLE (ID INT,UserName VARCHAR(50),Inches INT)
DECLARE @Category AS TABLE (ID INT,UserName VARCHAR(50),Category VARCHAR(50))
DECLARE @BlockProduction AS TABLE
(
[ID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [NVARCHAR](50) NULL,
[Item] [NVARCHAR](50) NULL,
[Inches] [NVARCHAR](50) NULL,
[Category] [NVARCHAR](500) NULL,
[Quantity] [FLOAT] NULL,
[ProductionDate] [DATE] NULL
)
DECLARE @Inch VARCHAR(20)
DECLARE @Cat VARCHAR(20)
SELECT SUM(Quantity) 'total quantity'
FROM @BlockProduction
WHERE (Inches = @Inch OR @Inch IS NULL) AND (Category = @Cat OR @Cat IS NULL)