SQL新手。
我尝试使用SQL语句检索数据库中产品记录的数据。
但是,我收到一条错误
Msg 8120,Level 16,State 1,Line 11 专栏' AggregatedSalesHistory.PriceZoneID'在选择列表中无效,因为它不包含在聚合函数或GROUP BY子句中。"
我正在使用Microsoft SQL Server Management Studio 2014,这是我运行的声明 -
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