Saturday, 5 May 2018

difference between Count(*) and Count(Column Name)

 Count(*) vs Count(column_name)

We use count(*) to get the total number of records.

SQL>select count(*) from emp2;

Note:-There is no difference between count(*) and count(1) .

SQL>select count(1) from emp2;

But there is a difference between count(*) and count(column_name) .Count(*) return the total number of records of table and count(column_name) return the count of records that have not null value in that column.

SQL>select count(empno) from emp2;

See the reference screen


 

Harry

Author & Editor

A technology enthusiast and addictive blogger who likes to hacking tricks and wish to be the best White Hacket Hacker of the World.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.