SQL Count Statement, SQL Tutorial, Global Guide Line Technology.
Bookmark Bookmark: SQL Count Statement, SQL Tutorial Forum | Blog |

      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 Create Views.           
 SQL Create Index.           
 SQL Alter Table.             
 SQL Drop Table.             
 SQL Truncate Table.      
 SQL Summary.                

SQL Tutorial >> SQL Count Statement.


     Back             Next     



SQL Tutorial will guide us another arithmetic function is COUNT. This allows us to COUNT up the number of row in a certain table. The syntax for this key work COUNT statement is as under.

Syntax for SQL Cont Statement

SELECT COUNT("column_name")
FROM "table_name"

For example, if we want to find the number of employees entries in our table,

Table Employees
FirstName LastName Email DOB Phone
Austin Hennery austin.it@gamail.com 24/11/1978 446 102-2222
Creston Narvon narvon_crest@hotmail.com 22/04/1976 443 325-4545
Kate Bladen kbladen@usa.net 01/05/1980 326 503-3232
Angela Hennery julieee@yahoo.co.uk 11/12/1977 326 323-8888
Bobbi Ferguson bobi123@kiwibox.com 10/02/1970 506 252-9875
Cute Alfa cafa@gmail.com 19/05/1972 506 272-4566

SELECT COUNT(FirstName)
FROM Employees

Result of SQL Count Statement:

Count(store_name)
6

SQL COUNT and DISTINCT Statements can be used together in a statement to fetch the number of distinct entries in a table. For example, if we want to find out the number of distinct employees Last Name, we'd type,

Example of SQL Count and Distinct Statements

SELECT COUNT(DISTINCT LastName)
FROM Employees

Result of SQL Count and Distinct statements:

Count(DISTINCT LastName)
5

Because the Last name of two employees Austin and Angela are same that's whey the last result is 5 even we have 6 records in our table of Employees the SQL Distinct key word show the unique recodes in a table.  Hope this section of SQL Tutorial coves the all needs for learning SQL Count And SQL Distinct Statements.

     Back             Next     
 

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

Copyright 2005 -  2018 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 309 visitors are online now