473,487 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Order of GROUP BY - does it matter?

Does the order of columns make a difference in the GROUP BY?
Woulde GROUP BY A, B, C
return different results than
GROUP BY C,A,B ?

Oct 23 '06 #1
3 10363
No.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"rcamarda" <ro*****@hotmail.comwrote in message
news:11**********************@f16g2000cwb.googlegr oups.com...
Does the order of columns make a difference in the GROUP BY?
Woulde GROUP BY A, B, C
return different results than
GROUP BY C,A,B ?
Oct 23 '06 #2
On 23 Oct 2006 05:23:26 -0700, "rcamarda" <ro*****@hotmail.comwrote:
>Does the order of columns make a difference in the GROUP BY?
Woulde GROUP BY A, B, C
return different results than
GROUP BY C,A,B ?
There is no difference. The set of rows returned is identical.

For an exception of sorts you have to go back to release 6.5 and
earlier. With those releases, if an ORDER BY was not provided, the
result set always ended up sorted on the GROUP BY; in that case the
same rows would be returned but the sequence would have changed
depending on the arrangement of the items in the GROUP BY clause. Many
people came to depend on that undocumented behavior and found there
were problems when they upgraded.

Roy Harvey
Beacon Falls, CT
Oct 23 '06 #3
rcamarda wrote:
Does the order of columns make a difference in the GROUP BY?
Woulde GROUP BY A, B, C
return different results than
GROUP BY C,A,B ?
In SQL Server 200x I can only think of one instance where it does make
a difference. If you use the ROLLUP clause then the values will get
summarized based on the order specified in the GROUP BY. This means
you'll see an entirely different set of totals depending on the GROUP
BY order.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--

Oct 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
5555
by: Jozef | last post by:
Hello, Does anyone here know for sure, when you do a For Each loop on a forms controls collection, does Access cycle through them in Alphabetical order or control ID or ???. Any ideas? ...
3
2131
by: Ryan Taylor | last post by:
Hello. I am trying to create a regular expression that will let me know if a string has the following criteria. Order does not matter in the string, but when building a regular expression it...
3
1262
by: tshad | last post by:
Does it matter whether Doctype is after the Page line? At the moment, I have my pages as so: <%@ Page Language="VB" trace="false" debug="true" AutoEventWireup="true" ContentType="text/html"...
2
2667
by: Viken Karaguesian | last post by:
Hello all, This question is half css and half html based, so I chose this group. I have a theortical question. When positioning floating <div>'s, how much does it matter what order you put itin...
2
7746
by: adrian.chandler | last post by:
Hi all, I have been using letter and symbol codes such as GNU< GNU\ GNU} GNUˆ in an Access table. I was surprised to see that when the table was sorted on this field, the order is: GNUˆ...
104
10753
by: Beowulf | last post by:
I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through...
10
353
by: int main(void) | last post by:
Hi all, In the following program, #include<stdio.h> int main(void) { int x = 10; int y = 10;
3
3970
by: Hartmut Dippon | last post by:
Hi all, I hope somebody can help me with following problem: I have an application where I can drag&drop files/dirs from within explorer onto my form. If multiple files/dirs are selected I...
15
1940
by: Jeroen | last post by:
Hi all, I've got a very specific question about the evaluation order in C++. Assume some kind of custom array class, with an overloaded subscript operator. In the following code: { my_array...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.