Commands available for Summarizing Data in SQL Server

What are the commands available for Summarizing Data in SQL Server?

We have CUBE or ROLLUP operators to generate summary reports. Both are part of the GROUP BY clause of the SELECT statement. We have COMPUTE or COMPUTE BY operators that are used with the GROUP BY clause.

CUBE Operator
The CUBE operator generates a result set in the form of multi-dimensional cube.

ROLLUP Operator
The ROLLUP operator generating reports that contain subtotals and totals.

What are the commands available for Summarizing Data in SQL Server?

Commands for summarizing data in SQL Server:
CommandDescriptionSyntax/Example
SUMSums related valuesSELECT SUM(Sal) as Tot from Table1;
AVGAverage valueSELECT AVG(Sal) as Avg_Sal from Table1;
COUNTReturns number of rows of resultsetSELECT COUNT(*) from Table1;
MAXReturns max value from a resultsetSELECT MAX(Sal) from Table1;
MINReturns min value from a resultsetSELECT MIN(Sal) from Table1;
GROUP BYArrange resultset in groupsSELECT ZIP,City FROM Emp GROUP BY ZIP
ORDER BYSort resultsetSELECT ZIP,City FROM Emp ORDER BY City
SQL server - Difference between CUBE operator & ROLLUP operator.
CUBE operator and ROLLUP operator - CUBE generates a result set that represents aggregates for all combinations of values in the selected columns........
What are the guidelines to use bulk copy utility of SQL Server?
SQL server bulk copy utility - While importing data, the destination table must already exist,While exporting to a file, bcp will create the file.......
SQL server capabilities - What are the capabilities of Cursors?
Capabilities of Cursors - Cursors can support various functionalities that are listed here.......
Post your comment