Showing posts with label all. Show all posts
Showing posts with label all. Show all posts

Thursday, 28 May 2015

SQL Query COUNT() function syntax

SCENARIO 
Suppose you have a table, now you want to know the number of records in it. Then COUNT function will do the job.

SYNTAX of COUNT()

SELECT COUNT(ColumnName) from Table_NAME;

Suppose we have a table named Table_NAME
as
sql result image

Now if we run query     SELECT COUNT(ColumnName1) from Table_NAME;

Output = 4
 or if we run  SELECT COUNT(ColumnName3) from Table_NAME;

Output= 2
it means if we are running count on columns then it neglects the null value columns.

If you want to know the total number of records in a table then you can simply use
SELECT COUNT(*) from Table_NAME;

SQL query Syntax Select all record from table

If you want to select everything from a table then use the follwing syntax:

SELECT * FROM table_name;

Here table_name is the name of the table of which you want to select the records.

This is basically see all record / data query.