Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Can Group Functions Be Used in the ORDER BY Clause
Can Group Functions Be Used in the ORDER BY Clause? - Oracle DBA FAQ - Understanding SQL SELECT Query Statements
✍: FYIcenter.com
If the query output is aggregated as groups, you can sort the groups by using group functions in the ORDER BY clause. The following statement returns how many employees are having the same salary in each department. The group output is sorted by the count in each group in descending order:
SQL> SELECT department_id, salary, count(*)
2 FROM employees GROUP BY department_id,
3 salary HAVING count(*) > 1
ORDER BY COUNT(*) DESC;
DEPARTMENT_ID SALARY COUNT(*)
------------- ---------- ----------
50 2500 5
50 3200 4
50 2800 3
80 10000 3
80 9500 3
50 3100 3
50 2600 3
.....
2007-04-20, 4998👍, 0💬
Popular Posts:
How To Return the Second 5 Rows? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries If yo...
In C#, what is a weak reference? Generally, when you talk about a reference to an object in .NET (an...
What are urlencode() and urldecode() functions in PHP? string urlencode(str) - Returns the URL encod...
What Happens If a Hyper Link Points to a Music File? - XHTML 1.0 Tutorials - Understanding Hyper Lin...
Can you explain Forms authentication in detail ? In old ASP if you where said to create a login page...