I am trying to get the avg difference between order requested delivery date and actual delivery date, by Destination. The below is giving me issues. Do you know where I am going wrong? The message I am getting is "Each GROUP BY expression must contain at least on column that is not an outer reference"
SELECT CONCAT(Locations.City, ', ', Locations.State) AS Destination,
AVG(DATEDIFF("Day", Orders.ReqDate, Orders.SchedDate)) AS "Average Diff"
FROM dbo.Orders,
dbo.Locations
WHERE dbo.Orders.OrderNum= dbo.Locations.OrderNum
GROUP BY 'Destination'