SQL Server - Difference between ORDER BY and the COMPUTE BY
lists - Feb 27, 2010 at 11:50 AM by Shuchi Gauri
Difference between ORDER BY and the COMPUTE BY lists.
Compute By Clause allows the user to see both detail and summary rows with one
Select statement. User can calculate summary values for subgroups, or a summary
value for the whole result set.
Order By Clause specifies sort order on columns selected by a select command.
SQL Server - Difference between ORDER BY and the COMPUTE BY
lists - May 05, 2009 at 22:00 PM by Rajmeet Ghai
Difference between ORDER BY and the COMPUTE BY lists.
COMPUTE BY is used to generate sub totals or summary of a result set. They are
used with an ORDER BY clause. The columns to be computed must be in the same
order as specified by Order by.
Example:
If order by is used as:
Order by x, y, z
Compute by can be used as:
COMPUTE BY x, y, z
COMPUTE BY y, z
COMPUTE BY x
SQL Server - Difference between ORDER BY and the Group BY
lists - June 21, 2009 at 09:00 AM by Amit Satpute
Difference between ORDER BY and the GROUP BY lists.
GROUP BY: When you query a SELECT and use a GROUP BY, the output rows are
grouped by the criteria stated by the GROUP BY.
ORDER BY: When you query a SELECT and use a ORDER BY, the output rows are sorted
by the criteria stated by the ORDER BY.
E.g.:
Consider a table that has the following data:
EMPNO
ENAME TITLE
----------- -----------
----------
2 SMITH CLERK
1 ALLEN
SALESMAN
3
WARD CLERK
4
JONES SALESMAN
5
MARTIN CLERK
Select * from emp order by empno;
1
ALLEN
SALESMAN
2
SMITH CLERK
3 WARD CLERK
4
JONES SALESMAN
5
MARTIN CLERK
Select * from emp group by title;
2
SMITH CLERK
3 WARD CLERK
5
MARTIN CLERK
1
ALLEN SALESMAN
4 JONES SALESMAN
Also read
SQL BETWEEN
SQL BETWEEN: The BETWEEN operator is used in a WHERE clause to select a range of
data between two values. The values can be numbers, text, or
dates..............
SQL INTERSECT allows combining results of two or more select queries. If a
record exists in one query and not in the other, it will be omitted from the
INTERSECT results..............
SQL SELECT INTO: The SELECT INTO statement selects data from one table and
inserts it into a different table. Used often for creating back
up’s............
Table, Data types, Function, Index, Constraint, Rule, Default, Stored
Procedures, Trigger, View..........
Answer - We have CUBE or ROLLUP operators to generate summary
reports. Both are part of the GROUP BY....
|