What is the difference between the following two sql
statements
select count(*) from <tablename>
select count(col_name) from <tablename>
Answers were Sorted based on User's Feedback
Answer / debasis
select count(*) from <tablename> returns the number of rows
in the table.
select count(col_name) from <tablename> return number
values in the column (Ignores null value in the colum). For
example if we execute the following 2 queries then
select count(*) form emp
select count(comm) form emp
The result will be
14
4
Is This Answer Correct ? | 34 Yes | 7 No |
Answer / kushi
for the First Qry,result is "No.of records"
for the second Qry,result is "No.of records for particular
columnname"
Is This Answer Correct ? | 17 Yes | 0 No |
Answer / sandeep
select count(*) from <tablename>
- return number of records from table
select count(col_name) from <tablename>
- return number of records where col_name is NOT NULL
- Null value is eliminated by an aggregate or other SET
operation.
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / sql2000
There seem to be a problem with the solutions provided by
the above.
Both the counts should provide the same result which is the
no of rows in the table.
count (*) will result in a bigger table scan than count
(col_name) hence its advisable to use count(1) while
calculating the count for a table.
Correct me if I am wrong...:)
Is This Answer Correct ? | 1 Yes | 3 No |
Explain the rules for designing files and file groups in sql server?
How do use Having,Group by,Group function in SQL?
Tell me what is normalization? Explain different forms of normalization?
Suppose you want to implement the many-to-many relationships while designing tables. How would you do it?
Do you have any idea about the tcl commands?
What is postgresql server?
1. SELECT SUM(sal) as “Gross Salary” from EMPLOYEES; 2. SELECT MAX(sal) as “Highest Salary” from EMPLOYEES; ouput should be in table format
Can you pass expressions to stored procedure parameters?
Write the queries for commands like Create Table, Delete table, Drop Table etc.
0 Answers HPCL, Hughes Systique Corporation,
If a user does not have permission to a table, but has permission to a view created on it, will he be able to view the data in table?
What is the Disadvantage of indexed sequential file.
What are the different ways of moving data/databases between servers and databases in SQL Server?