Global GuideLine Home HTML Tutorial JavaScript Tutorial SQL Tutorial CSS Tutorial SEO Tutorial XML Tutorial XSLT Tutorial Articles Tutorial Interview Questions and Answers Guide Jobs GuideLine Bookmark With Google Bookmark With Yahoo Bookmark With FaceBook Bookmark With Live Follow @GlobalGuideLine on Twitter Bookmark Global GuideLine
SQL Group By Clause, SQL Tutorial, Global Guide Line Technology.
Bookmark this webpage. Bookmark: SQL Group By Clause, SQL Tutorial Global Guideline is UNITED STATES's favorite website

      Home                    

Basic SQL Guide.           
SQL Introduction.               
 What is Table?                  
 SQL Create Table.            
 SQL Insert Statement.      
 SQL Select Keyword.        
 SQL Order by clause.        
 SQL Count Statement.      
 SQL Group By Clause.
 SQL Having Clause.          
 SQL Alias Tables.             
 SQL Join Tables.              
 SQL Outer Join.               
 SQL Update Statement.   
 SQL Delete Statement.    
 SQL Distinct Keyword.      
 SQL Where Keyword.       
 SQL And Or Keyword.      
 SQL In Keyword.              
 SQL Between Keyword.   
 SQL Like Keyword.          
 SQL Functions.                
 SQL Concatenate.           
 SQL Substrings.               
 SQL Trim Function.         
 SQL Constraints.              
 SQL Primary Key.            
 SQL Foreign Key.            
 SQL Cerate Views.           
 SQL Create Index.           
 SQL Alter Table.             
 SQL Drop Table.             
 SQL Truncate Table.      
 SQL Summary.                

SQL Tutorial >> SQL Group By Clause.


     Back             Next     



Now here in SQL Tutorial we return to the aggregate functions of SQL Group by clause. Remember we used the SUM keyword to calculate the total number of the employees records in our table of employees. Well, we need to do two things: First, we need to make sure we select the employees name as well as total salary. Second, we need to make sure that all the salary figures are grouped by month. The corresponding SQL syntax for SQL group by keyword is,

Syntax for SQL Group By Clause

SELECT "column_name1", SUM("column_name2")
FROM "table_name"
GROUP BY "column_name1"

Let's illustrate using the following table,

Table Employees_Salary
FirstName Month Salary
Austin January 11000$
Creston January 11000$
Kate January 12000$
Angela January 10900$
Bobbi January 12000$
Cute January 13000$
Austin February 11100$
Creston February 11100$
Kate February 12100$
Angela February 11000$
Bobbi February 12200$
Cute February 13300$

Example of SQL Group By Clause

SELECT Month, SUM(Salary)
FROM Employees_Salary
GROUP BY Month
 

Result:

Month SUM(Salary)
January 69900$
February 70800$

The SQL GROUP BY keyword is used when we are selecting multiple columns from a table (or tables) and at least one arithmetic operator appears in the SELECT statement. When that happens, we need to GROUP BY all the other selected columns, i.e., all columns except the one(s) operated on by the arithmetic operator. Hope this SQL Tutorial section is enough to explain SQL Group By Clause for beginners.


     Back             Next     
 
In order to link this page as Reference, click on below text area and pres (CTRL-C) to copy the code in clipboard or pres right click then copy the following lines after that past into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code:

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright © 2005-2006 www.globalguideline.com All rights reserved. Join Global Guide Line community. 230 visitors are online now