what is the difference between count(*) and count(1) ?



what is the difference between count(*) and count(1) ?..

Answer / Brijesh Kumar Singh

In SQL Server, both count(*) and count(1) return the number of rows in a result set. However, there's a slight performance difference: count(*) performs better because it doesn't require an expression to be evaluated for each row, whereas count(1) does. This means count(1) will perform a small amount of calculation on every row, making it slightly slower compared to count(*).

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

what is the difference detween pairwise comparison subquary and non pairwise comparison subquary?

2 Answers  


Where does the copy job runs in the log shipping primary or secondary? : sql server database administration

1 Answers  


Syntax to find the used space and free space of the Data file in a database(SQL Server). Following queries didn't give the exact Used space and Free Space Information sp_spaceused;DBCC showfilestats;exec MyDbName.dbo.sp_spaceused;SP_HELPFILE Can any one tell me the query for how to find the exact used data file space and free space in a Data File?

2 Answers   Cognizant,


Difference between Cluster and Non-cluster index?

32 Answers   Accenture, Agility e-Services, eClinicalWorks, HCL, Infosys, Oracle, Satyam, Yardi,


What Is The Difference Between Primary Key & Super Key

3 Answers   Accenture,


How to count groups returned with the group by clause in ms sql server?

1 Answers  


Explain sql server service broker?

1 Answers  


Define Unique Key?

1 Answers   HCL,


How to create new tables with "create table" statements in ms sql server?

1 Answers  


What is self contained sub query?

0 Answers  


How to connect of datebase with sql express.?

1 Answers   MCN Solutions,


What is b tree index?

1 Answers  


Categories