WITH Sales_CTE (SalesPersonID, SalesOrderID, SalesYear) AS ( SELECT SalesPersonID, SalesOrderID, YEAR(OrderDate) AS SalesYear FROM Sales.SalesOrderHeader WHERE SalesPersonID IN ('+ @param +') ) SELECT SalesPersonID, COUNT(SalesOrderID) AS TotalSales, SalesYear FROM Sales_CTE GROUP BY SalesYear, SalesPersonID
DECLARE @SQLQuery AS NVARCHAR(MAX) SET @SQLQuery = 'SELECT * FROM table1 WHERE EmployeeID in(' + @param +')' EXECUTE(@SQLQuery)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)