CountDistinct.mdb (Intermediate) |
Post Reply |
Author | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Roger Carlson
Microsoft MVP Joined: 20 Feb 2008 Status: Offline Points: 261 |
Post Options
Thanks(0)
Posted: 06 Jun 2012 at 7:26am |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SQL Server has a nice built-in function called COUNT DISTINCT, which is missing in Access SQL. What does COUNT DISTINCT do? Well, there are times when you want to count distinct values in a query, that is, a count of values without duplicates. For instance, given the following table, how many distinct customers have orders? ORDERS
In SQL Server, I can do this: SELECT COUNT(DISTINCT Customer) AS CountOfCustomer FROM Orders Which will give me the following:
In Access, if I use the Distinct predicate with the count: SELECT DISTINCT Count(Customer) AS CountOfCustomer FROM Orders; I get:
Since Access SQL does not have the Count Distinct function, what can I do? This sample shows you. Download Access 2000+: CountDistinct.zip |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sponsored Links | Want a good read? Try The Summer of His Life (available on Amazon!) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |