The Difference between 'Count' and 'Count(*)'

Answers were Sorted based on User's Feedback



The Difference between 'Count' and 'Count(*)'..

Answer / guest

'Count': Counts the number of non-null values.
'Count(*)': Counts the number of rows in the table,
including null values and duplicates.

Is This Answer Correct ?    42 Yes 2 No

The Difference between 'Count' and 'Count(*)'..

Answer / nikita

I agree with the above answer

Is This Answer Correct ?    13 Yes 0 No

The Difference between 'Count' and 'Count(*)'..

Answer / vijay dev saxena

Count(exp): Counts the number of rows excluding null values.
Count(*) : Counts the number of rows including null and
duplicates records.

Is This Answer Correct ?    13 Yes 0 No

The Difference between 'Count' and 'Count(*)'..

Answer / selvaraj.v

In SQL Server 2000,
Query:
------
select count from employees
Answer:
------
invalid column name 'count'


In SQL Server 2000,
Query:
------
select count(*) from employees

Answer:
-------
No column name
----------------
1. 20

Is This Answer Correct ?    9 Yes 0 No

The Difference between 'Count' and 'Count(*)'..

Answer / t.lakshmi

count - It returns the non null values
count(*) - It returns the null values and duplicate values

Is This Answer Correct ?    9 Yes 0 No

The Difference between 'Count' and 'Count(*)'..

Answer / vijay dev saxena

Count(expr) -> returns the number of records in the table
where the expr is not null in the particular column.
Count(*) -> returns the number of all records in the table.
(including duplicates and those with nulls)

Is This Answer Correct ?    6 Yes 0 No

The Difference between 'Count' and 'Count(*)'..

Answer / sachin rathi

Count(column name or exp) returns the no. of records for a
specific/particular column of table excluding null values
whereas Count(*) returns all the rows/records in the table
including duplicated and null values

Is This Answer Correct ?    6 Yes 1 No

The Difference between 'Count' and 'Count(*)'..

Answer / manisha

count fetches non-null value from out of a query but count
(*) includes null values also.

Is This Answer Correct ?    5 Yes 0 No

The Difference between 'Count' and 'Count(*)'..

Answer / harish sharma

Count(column_name) returns the number of records in the
table where the column value is not null for the particular
column.
Count(*) returns the number of all records in the table.
(including duplicates and those with nulls)

Is This Answer Correct ?    5 Yes 1 No

The Difference between 'Count' and 'Count(*)'..

Answer / rajeeva tripathi

count - It returns the non null values
count(*) - It returns the null values and duplicate values

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What changes in the front end code is needed if mirroring is implemented for the high availability? : sql server database administration

0 Answers  


What are the various Operating system files that every SQL server 2005 database has and what is the purpose.

0 Answers   Microsoft,


What will be query used to get the list of triggers in a database?

0 Answers  


Difference between rowid and rownum in SQL?

1 Answers   Virtusa,


As a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this?

0 Answers  






What are binary string data types in ms sql server?

0 Answers  


Join 3 tables (table1, table2 & table3) in a single query. Inner join should be applied for table1 & table 2 and left outer join for table1 & table3 where table2.dept is ABC

2 Answers  


Does partitioning ssd reduce performance?

0 Answers  


how to replace double quotes by single quotes in sql server

2 Answers   CAC,


Can group functions be mixed with non-group selection fields in ms sql server?

0 Answers  


What are the recovery models in sql server 2000?

0 Answers  


what is lazy writer?

1 Answers   Wipro,


Categories