Distinct Count with Group By Clause in Access

Asked By Siddique Ahmed
03-Nov-09 01:50 AM
Earn up to 0 extra points for answering this tough question.

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?

  DISTINCT COUNT

F Cali replied to Siddique Ahmed
04-Nov-09 03: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.

Create New Account