Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't get my GROUP BY clause to work
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Can't get my GROUP BY clause to work
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01255597
Message ID:
01255597
Views:
65
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
Next
Reply
Map
View

Click here to load this message in the networking platform