I'm getting this error on my select statement: "Msg 164, Level 15, State 1, Line 12
Each GROUP BY expression must contain at least one column that is not an outer reference."
Here is the statement - anyone see my problem? been driving me nuts all day!
INSERT INTO #SummarizedData1(
ControlDateKey,
ActualDateKey,
ControlPeriodStartKey,
ControlPeriodEndKey,
Store,
Units,
Sales,
Markdown)
SELECT CYDateKey = @FlashControlDateKey,
dbo.FlashData_CurrentYear.FDAT,
PeriodStartKey = @FlashControlPeriodStartKey,
PeriodEndKey = @FlashControlPeriodEndKey,
dbo.FlashData_CurrentYear.FSTR,
SUM(dbo.FlashData_CurrentYear.FQTY) AS Units,
SUM(dbo.FlashData_CurrentYear.FSLS) as Sales,
SUM(dbo.FlashData_CurrentYear.FMKD) as MarkDown
FROM dbo.FlashData_CurrentYear
where dbo.FlashData_CurrentYear.FDAT >= @FlashControlPeriodStartKey
AND dbo.FlashData_CurrentYear.FDAT <= @FlashControlPeriodEndKey
group by @FlashControlDateKey,dbo.FlashData_CurrentYear.FDAT,
@FlashControlPeriodStartKey, @FlashControlPeriodEndKey,
dbo.FlashData_CurrentYear.FSTR
select * from #SummarizedData1
ICQ 10556 (ya), 254117