Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Using COUNT(expression) and COUNT(ALL expression)

Author  Topic 

Well123
Starting Member

3 Posts

Posted - 2007-07-16 : 07:59:36
Hello all,

Answer please: what's difference between COUNT(expression) and COUNT(ALL expression) aggregate functions?

Thanks a lot

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-16 : 08:05:05
and books online = sql server help isn't clear enough?


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Well123
Starting Member

3 Posts

Posted - 2007-07-16 : 08:14:50
[quote]Originally posted by spirit1

and books online = sql server help isn't clear enough?

no, it isn't. I know, that ALL is default argument, but this answer isn't right for my teacher.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-16 : 08:29:01
ALL = Applies the aggregate function to all values. ALL is the default.

USE master;
SELECT COUNT(name), COUNT(ALL name), COUNT(DISTINCT NAME), COUNT(*)
FROM spt_values

-- results
-- 298 298 290 2346

In microsoft sql server COUNT(name) and COUNT(ALL name) are the same thing

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Well123
Starting Member

3 Posts

Posted - 2007-07-16 : 08:45:49
quote:
Originally posted by spirit1

ALL = Applies the aggregate function to all values. ALL is the default.

USE master;
SELECT COUNT(name), COUNT(ALL name), COUNT(DISTINCT NAME), COUNT(*)
FROM spt_values

-- results
-- 298 298 290 2346

In microsoft sql server COUNT(name) and COUNT(ALL name) are the same thing

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp



Thank you, for answer!
Go to Top of Page
   

- Advertisement -