What is this Site!!

All about Real time requirements in Orale Stay Tune!!

Friday, February 8, 2008

SQL Server

Compute By Clause

The compute and compute by clause are used to produce new rows of summary and detail data. They use the aggregate functions. The COMPUTE clause return detail rows and a grand total summary row. The compute by clause return the new rows of summary data, much like Group By clause, but it returns the rows as sub-groups with summary values

One has to use Order By clause before using Compute By clause


Example


SELECT type, SUM (ytd_sales)
FROM titles
ORDER BY type COMPUTE SUM(ytd_sales) BY type