Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other Microsoft Access Posts   Ask New Question  Ask New Question With Power Editor

Distinct Count with Group By Clause in Access
Siddique Ahmed posted at Tuesday, November 03, 2009 1:50 AM

Hi All,

I want to get a distinct count in a group by clause using Access. My table looks like following:

Two Fields:

1) Customer_SSN:  A double data type

2) Date_of_Joining: Data type is date/time

Now I want to have a result in the following form:

Month      Total_Joining      Unique_Joining 

Jan-09         874                     450

Feb-09      1200                     800

I have done half of the part:

SELECT month(date_of_joining), count(Customer_SSN)
FROM [Joining_history]
GROUP BY month(date_of_joining);

Can any one please help me in adding the third column?

Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0
DISTINCT COUNT
F Cali provided a rated reply to Siddique Ahmed on Wednesday, November 04, 2009 3:55 PM

Try this statement:

SELECT month(date_of_joining), count(Customer_SSN), count(DISTINCT Customer_SSN)
FROM [Joining_history]
GROUP BY month(date_of_joining);

 I tested this statement in SQL Server and it worked.

Reply    Reply Using Power Editor
How well do you know SQL? Find out with the free test assessment from SQL Server Helper:
http://www.sql-server-helper.com/free-test/default.aspx
  Rank Winnings Points
November 3 $65.00 168
October 0 $0.00 0