SQL newbie.
I'm trying to retrieve data for a product record in a databse using an SQL statement.
However, I get an error that says
Msg 8120, Level 16, State 1, Line 11 Column 'AggregatedSalesHistory.PriceZoneID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."
I'm using Microsoft SQL Server Management Studio 2014 and this is the statement I ran-
select
PriceZoneID,
Date,
CAST(ash.Date as date) as Date,
SUM(ash.Sales) as Units,
SUM(ash.Sales * ash.Price) AS CashSales
from AggregatedSalesHistory AS ASH
INNER JOIN ForecastProductScenario AS LRF
ON ash.ProductSID = lrf.ProductSID AND ash.date = lrf.ForecastDate AND ash.PriceZoneID = lrf.ZoneID AND ash.SegmentID = lrf.SegmentID
WHERE ash.PriceZoneID = 2
AND ash.ProductSID = '56358E18-7B49-4346-8B70-DC5DE122DB59'
AND DATE = 12/10/2014