Difference Between Count(*) and Count(1) in SQL

There is no difference between Count(*) and Count(1). They are same both in terms of result and performance.

Actual syntax of Count() function is as follows.

Syntax:


As per syntax, you can use either * or an expression as an argument to function. Here 1 is a non-null expression, so it is same as Count(*). 

Brief Introduction:

1. Count returns the number of rows returned by the query.

Some examples of Count:

1. select count(*) from employees;
2. select count(salary) from employees;
3. select count(distinct manager_id) from employees;

References:

a. https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions032.htm

Comments