|
|
|
In SQL Server 6.5 and previous versions, the GROUP BY clause in a SELECT statement was carried out by temporarily sorting the resultset before grouping similar rows, therefore the end result was always sorted. For this reasons, many programmers omitted the ORDER BY clause, because the result was sorted anyway
SQL Server 7.0 has modified how the GROUP BY is internally resolved, and in some cases it groups rows using temporary hash tables. In this case the returned rows aren't sorted on the field specified in the GROUP BY clause. The bottom line is: if you want that a sorted result from a SELECT statement with a GROUP BY clause in SQL Server 7, you must explicitly provide the ORDER BY clause.
The same warning applies to UNION queries without the ALL keyword. Under previous SQL Server versions these queries always required an internal sort, thus the result was always sorted. This isn't necessarily true in SQL Server 7. |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
 |

|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|