Related to the following:
What SQL can I use to retrieve counts from my payments data?
SQL : how can i count distinct record in MS ACCESS
Sample data:
Student ID | School | School Service Type | PaymentStartDate | PaymentEndDate | FiscalYear
001 ABC ED 2014-01-02 2014-08-02 2014
001 ABC ED 2014-06-02 2014-06-05 2014
002 ABC ED 2014-04-02 2014-08-05 2014
002 DEF ED 2014-06-01 2014-06-05 2014
002 DEF ED 2014-02-01 2014-06-15 2014
002 ABC EZ 2014-03-01 2014-07-01 2014
003 ABC EZ 2014-01-30 2014-07-15 2014
003 ABC EZ 2014-03-01 2014-07-01 2014
What I want my count to look like:
Month | FiscalYear | School | School Service Type | Count
May 2014 ABC ED 2
May 2014 ABC EZ 2
May 2014 DEF ED 1
June 2014 ABC ED 2
June 2014 ABC EZ 2
June 2014 DEF ED 1
June 2014 DEF EZ 0
What my current SQL Server code looks like:
SELECT FiscalYear
,'11 May' AS PAYMENT_MONTH
,School
,School Service Type
,COUNT(DISTINCT Student ID) AS UNIQUE_STUDENT_COUNT
FROM [dbo].[MYODBCTABLE]
WHERE FiscalYear = '2014'
AND School Service Type IN ('ED', 'EZ')
AND MONTH(PaymentStartDate) = 05
GROUP BY
FiscalYear
,School
,School Service Type
ORDER BY 1,2,3
UNION
SELECT FiscalYear
,'12 JUNE' AS PAYMENT_MONTH
,School
,School Service Type
,COUNT(DISTINCT Student ID) AS UNIQUE_STUDENT_COUNT
FROM [dbo].[MYODBCTABLE]
WHERE FiscalYear = '2014'
AND School Service Type IN ('ED', 'EZ')
AND MONTH(PaymentStartDate) = 06
GROUP BY
FiscalYear
,School
,School Service Type
ORDER BY 1,2,3
Desire: To create analogous SQL code that will allow me to perform this process in the Access 2010 environment.
Challenge:
1) Microsoft Access lacks the Count Distinct function.
I have been trying to follow the instructions laid out here, but I've had no luck in getting the SQL statements I derive to work properly.
As always, thank you for your time.