I can't for the life of me figure out why I get an error of "Invalid column name 'AvgDaily'" on the following code. Any ideas?
create table #TMP_Daily_Avg_Rollup
(
Zone varchar(20),
fkiItem int,
fkiLocation int,
AvgDaily decimal(12,3)
)
Insert into #TMP_Daily_Avg_Rollup (Zone, fkiItem, fkiLocation, AvgDaily)
Select
tte.Zone, tte.fkiItem, tte.fkiLocation,
(sum(tte.TransQty) / @UsageDaysLong) as AvgDaily
From
#TMP_Trans_Events tte
Group By
tte.Zone, tte.fkiItem, tte.fkiLocation
Order By
tte.fkiItem