The
University of Vermont SQL ORDER by and GROUP by.The SQL "Order by" clause lets you display results sorted by one or more fields. SELECT ENAME FROM EMP ORDER BY ENAME; By definition, relational tables have no fixed sort order. Each time
you reference the data
SELECT ENAME, DEPTNO FROM EMP ORDER BY DEPTNO DESC ENAME; The SQL "Group by" clause lets you aggregate rows. This is great
for counting all the thises in
SELECT DEPTNO, COUNT(*) FROM EMP GROUP BY DEPTNO; SELECT AVG(SAL) FROM EMP GROUP BY DEPTNO;
|
Brought
to you through the courtesy of Computing
and Information Technology, University of Vermont. Copyright ©
1996 The University of Vermont and others. All rights reserved.
The University supports both institutional and personal web pages. The views expressed on personal web pages are strictly those of the author, and are not reviewed or approved by the University of Vermont Send questions and comments to Keith.Kennedy@uvm.edu Read the
Webmaster's
Policies.
|