-- EmployeeSalesSummary_EmpSalesMonth SELECT C.FirstName + ' ' + C.LastName AS Employee, DATEPART(Year, SOH.OrderDate) AS OrderYear, DATEPART(Month, SOH.OrderDate) AS OrderMonthNum, DATENAME(Month, SOH.OrderDate) AS OrderMonth, PC.Name AS ProdCat, SUM(SOD.LineTotal) AS Sales FROM Sales.SalesOrderHeader SOH INNER JOIN Sales.SalesOrderDetail SOD ON SOH.SalesOrderID = SOD.SalesOrderID INNER JOIN Sales.SalesPerson SP ON SOH.SalesPersonID = SP.BusinessEntityID INNER JOIN HumanResources.Employee E ON SP.BusinessEntityID = E.BusinessEntityID INNER JOIN Person.Person C ON E.BusinessEntityID = C.BusinessEntityID INNER JOIN Production.Product P ON SOD.ProductID = P.ProductID INNER JOIN Production.ProductSubcategory PS ON P.ProductSubcategoryID = PS.ProductSubcategoryID INNER JOIN Production.ProductCategory PC ON PS.ProductCategoryID = PC.ProductCategoryID WHERE (DATEPART(Year, SOH.OrderDate) <= @ReportYear) AND (DATEPART(Month, SOH.OrderDate) = @ReportMonth) AND (SOH.SalesPersonID = @EmpID) GROUP BY C.FirstName + ' ' + C.LastName, DATEPART(Year, SOH.OrderDate), DATEPART(Month, SOH.OrderDate), DATENAME(Month, SOH.OrderDate), PC.Name