Count(*) and Count(column)

 Count(*) and Count(column)

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


No comments:

Post a Comment