Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incorrect Syntax Error
Message
From
12/06/2008 19:33:25
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01323625
Message ID:
01323636
Views:
19
>>>Now I'm getting:
>>>
>>>"Column 'Product.sProduct_Desc1' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."
>>>
>>>I don't understand why all the columns listed in the SELECT clause have to be in the GROUP BY clause.
>>>
>>>Can you enlighten me?
>>
>>If column is not in the GROUP BY clause than SQL engine wouldn't know what record it should come from. IOW, you did not provide enough info for SQL Engine to perform the query.
>
>
>"....than SQL engine wouldn't know what record it should come from"
>
>Huh?? I don't get this.

Sergey is the best one to explain this really, but to me it has to do with getting non-normalized results. You could have a record that has the exact same value in one of the fields your selecting, but if you don't include it in your GROUP BY, then the engine doesn't know which one to give you. If you do include it in the GROUP BY, then it knows that you want to go to another level and it will combine those two into one record. This is not how Foxpro works prior to VFP8. In versions after VFP7, you can SET ENGINEBEHAVIOR 70 and will be able to do what you want to do in Foxpro. SQL does not allow you to do that. It is ultimately for your own good so you will get clean results that do not have duplicate or lost records.
Previous
Reply
Map
View

Click here to load this message in the networking platform