Monday, February 9, 2015

SQL SELECT COUNT


SQL SELECT COUNT


The SQL COUNT() function is used to return the number of rows in a query. The count() function is generally used in SQL SELECT function. It is very useful to count the numbers of records.
Let's see the syntax of SQL COUNT statement.
  1. SELECT COUNT (expression)  
  2. FROM tables  
  3. WHERE conditions;  
Let's see the examples of sql select count function.

SQL SELECT COUNT(column_name)

  1. SELECT COUNT(nameFROM employee_table;  
It will return the total number of names of employee_table. But null fields will not be counted.

SQL SELECT COUNT(*)

  1. SELECT COUNT(*) FROM employee_table;  
The "select count(*) from table" is used to return the number of records in table.

SQL SELECT COUNT(DISTINCT column_name)

  1. SELECT COUNT(DISTINCT nameFROM employee_table;  
It will return the total distinct names of employee_table.

No comments:

Post a Comment