ORDER BY
|
GROUP BY
|
Sorts generated output.
|
Groups rows. The output might not be in group order, however.
|
Any columns (even columns not selected) may be used.
|
Only selected columns or expressions columns may be used, and every selected column expression must be used.
|
Never required.
|
Required if using columns (or expressions) with aggregate functions.
|
More often than not, you will find that data grouped using GROUP BY will indeed be output in group order. But that is not always the case, and it is not actually required by the SQL specifications. Furthermore, even if your particular DBMS does, in fact, always sort the data by the specified GROUP BY clause, you might actually want it sorted differently. Just because you group data one way (to obtain group specific aggregate values) does not mean that you want the output sorted that same way. You should always provide an explicit ORDER BY clause as well, even if it is identical to the GROUP BY clause.
Don't Forget ORDER BY As a rule, anytime you use a GROUP BY clause, you should also specify an ORDER BY clause. That is the only way to ensure that data will be sorted properly. Never rely on GROUP BY to sort your data.
分享到:
相关推荐
Teach Youself UML in 24 Hours
Sams Teach Youself SAP in 24 Hours(sap基础教程英文原版)
In fact,Teach Yourself C in 24 Hoursprovides a good starting point for you in C pro- gramming. It covers important topics in C programming,and lays a solid foundation for a serious beginner like you. ...
Teach.youself.UML.in.24.hours,3rd.edition.pdf 学uml最好的自学书
php初学者的首选图书,sams teach yourself 系列丛书之一。非常好
Teach.Youself.Perl.5.in.21.Days
国外经典Java教材,Sams Teach Youself Java in 21 Days第六版的源代码,本书涉及Java7和Android的知识,帮助读者编写高效的Java程序和Android应用! 作者:Rogers 译者:冯志祥等 出版社:人民邮电出版社
此资源尾pdf格式,英文教程,这个教程使用与初学者,学的较快。
java 源码书籍
这是SAMS Teach youself boorland C++Builder in 21 days一书的源代码,中文名Borland C++Builder3.0自学培训教程(希望公司出版).但此中文版并未配源码,使自学大打折扣.现在我把这套源码放在这,希望有这本书的读者能...
There is more, please explore youself and have fun. 6. To run the new sample page: enter /localhost/<vir-dir>/admin/loginControlTest1221.aspx, if you have followed the installatiion procedure below....
Here are FFTW lib and dll files compiled by GCC4.5 and VC2010 in Win7. But I suggest you compiling it by youself in you computer, or there will be some unpredictable errors!
4.row definition by youself (Render) 5.succinct code (size of origin code is under 10k, after compress it is under 3k), update easily. 6.easy study and use 7.easy custom css style Just a little ...
Extract to any folder, and you can use it, make youself happy:) THIS IS A THIRD-PARTY SOFTWARE. IT IS PROVIDED "AS IS", WITHOUT ANY WARRANTY. If it does not meet your needs, please install the full ...
SEO For 2016 – The Complete Do It Yourself SEO Guide
This is a library of the AnimatorSet,it has three move path and many animation,you can make a easy animation of view by youself. animation of View i did not finish it at this time Demo MovePath ...
java 自学指南java初学者的宝典
app lock for you to lock youself apps which you can not see for others
#Hyper Ajax 对象 ... 如果您不熟悉 ... Take a look at the <a>Code Reference</a> so you can load the class and familiarize youself with the constructor. Then try out example 3 on the right, it is the m
简明批处理教程22009年10月20日 星期二 下午 05:35 最近对于批处理技术的探讨比较热,也有不少好的批处理程序发布,但是如果没有一定的相关知识恐怕不容易看懂和理解这些批处理文件,也就更谈不上自己动手编写了,古...