I'm trying to run a report that joins two tables in order to show how many time a 42 inch monitor was order each month. The t-sql I wrote is not working. I'm getting an error of "Each GROUP BY expression must contain at least one column that is not an outer reference." I'm not sure how to fix this error.
Here's my code:
SELECT Month(cco.arrivalDate) as 'Month of Show', COUNT(cco.componentID) as 'Order Count'FROM customComponentsOut AS cco INNER JOIN customComponentsInStock AS cci ON cco.componentID = cci.componentIDWHERE (cci.type = N'monitor')AND cci.size = '42'AND cco.arrivalDate BETWEEN '1/1/2015' AND '12/31/2015'GROUP BY 'Month of Show'