Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any Set EngineBehavior 70
Message
General information
Forum:
ASP.NET
Category:
Databases
Miscellaneous
Thread ID:
01531768
Message ID:
01531778
Views:
51
>When I use Group By in T-Sql, I have to include ' 'ALL' the fields I am grouping by. This has got to be a real pain.
>Is there any Corresponding 'Set Enginebehavior 70' in SQL to overcome this problem.
>I presume it also takes a lot longer to group By 10 fields (which might be 300 characters wide if I include Decriptions) as opposed to only being possibly 20 characters (Or better still 2 numeric fields )
>e.g.
>Select MyAccountNum,MyInventoryNum,MyAccountName,MyInventoryName, Sum(MyValue) as MySum
> from MyTable
>Group By MyAccountNum,MyInventoryNum,MyAccountName,MyInventoryName
>
>In above case, I really only want to Group By 2 Integer Values (Which should be extrememly Fast) but I am forced to group by
> 2 Integer values and 2 Character Fields (each of say 100 characters each). This gets a lot worse if ther are numerous description fields.
>
>In that the original table will always have a one to one Number and Description combination, after the grouping it does not matter which descriptions I end up with from the original tables.
>

Naomi has already told you how you can do it. Now I'm going to try to tell you why you shouldn't <g>, There is a reason the GROUP BY rules are what they are. When you include columns which are not part of the GROUP BY expression, an arbitrary value will be returned in the result set. It's not valid. Maybe in some cases it won't matter, the values will all be the same, but do you really want your code to whistle past the graveyard like that?

I do give you props for wanting to do so for performance reasons, not just "That's the way I've always done it in FoxPro."
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform