The Difference between 'Count' and 'Count(*)'
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
You have several tables, and they are joined together for querying. The tables contain both clustered indexes and non clustered indexes to optimize performance, how should you distribute the tables and their indexes onto different file groups?
What is transact-sql ddl trigger?
Does index speed up select statements?
What have included columns when we talk about sql server indexing?
How to change a login name in ms sql server?
Can you create a logon trigger in sql server 2005 express edition?
What are the different ways you can create databases in sql server?
What objects does the fn_my_permissions function reports on? : sql server security
Explain the collation?
Write SQL queries on Self Join and Inner Join.
What is the use of partition by in sql server?
What are the types of resultset?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)