I'm still pretty new to SQL and am having issues. I am using a variation of the classic Northwind Database. I am using Microsoft SQL Server Management Studio.
Here is the problem:
/*
Join Products and ProductVendors to display by product, the product
number, the average wholesale price, and the average retail price.
*/
Here's what I've got:
SELECT Products.productNumber As [Product Number],
CAST(AVG(wholesalePrice) as decimal (8,2)) As [Average Wholesale Price],
CAST(AVG(retailPrice) as decimal (8,2)) As [Average Retail Price]
FROM Products INNER JOIN ProductVendors
ON Products.productNumber = ProductVendors.productNumber
Here's the error I get:
Msg 8120, Level 16, State 1, Line 2
Column 'Products.productNumber' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.