SQL - Structured Query Language

GROUP BY Clause



GROUP BY clause is used to selected set of rows into a set for summary rows by the values of one or more columns or expressions in SQL Server 2012. One row is returned for each group. Aggregate functions in the SELECT clause list provide information about each group instead of individual rows.

-- Example 28 --

 

SELECT COUNT(*), Prod_Tax FROM Product

GROUP BY Prod_Tax

 

SELECT MIN(Exp_Date) FROM Product

GROUP BY Exp_Date

 

SELECT MAX(Exp_Date) FROM Product

GROUP BY Exp_Date

 

SELECT AVG(Prod_Tax) FROM Product

GROUP BY Prod_Tax

 

SELECT SUM(Prod_Tax) FROM Product

GROUP BY Prod_Tax


Query Output Screen

More Reference URL: http://technet.microsoft.com/en-us/library/ms177673.aspx

* * * * *


Email Your Comment To AUTHOR