Hi all i am newbie in SQL
?
What is the difference between count(*) and count(1) in SQL
?
Thank You
Hi all i am newbie in SQL
?
What is the difference between count(*) and count(1) in SQL
?
Thank You
There is no difference.
Select Count(*) from TableName
Select Count(1) from TableName
It is very common perception that the Count(1) perform better compared to Count(), however it is not the case. If you test by looking at the execution plan, you will see same action being performed by both the commands and same number of rows being scanned. The time taken may be slightly different interms of CPU usage for count() , but is almost same as count(1). The confusion is generally because in older version of some RDBMS products like Oracle has difference in performance for select count(*) and count(1), but recent releases does not have any difference.
Refer this : http://www.sqlserverf1.com/difference-between-select-count-and-count1-in-sql-server/
and