I need to get a count of cases associated with vendors, grouped by month over a time between two dates. The month part is where I have trouble. I don't know how to make the query "count" each case number by vendor for each month. Ideally what I would get is something like
Vendor Month Count
1 1/1/2018 10
2 1/1/2018 20
1 2/1/2018 9
2 2/1/2018 21
etc.
The code I have is below. Any help is appreciated
SELECT DISTINCT PCC_Vendor_Number.PCC_VNum, Placements.CRPCaseNum
FROM (PCC_Vendor_Number INNER JOIN Placements ON PCC_Vendor_Number.PCC_VNum = Placements.PCC_VNum) INNER JOIN Client ON Placements.CRPCaseNum = Client.CRPCaseNum
WHERE (((Placements.datDischarge)>=DateAdd("m",-15,DateSerial(Year(Date()),Month(Date()),1)) Or (Placements.datDischarge) Is Null) AND ((Placements.datAdmit)<DateAdd("m",-15,DateSerial(Year(Date()),Month(Date()),1))))
GROUP BY PCC_Vendor_Number.PCC_VNum, Placements.CRPCaseNum
ORDER BY PCC_Vendor_Number.PCC_VNum;
Vendor Month Count
1 1/1/2018 10
2 1/1/2018 20
1 2/1/2018 9
2 2/1/2018 21
etc.
The code I have is below. Any help is appreciated
SELECT DISTINCT PCC_Vendor_Number.PCC_VNum, Placements.CRPCaseNum
FROM (PCC_Vendor_Number INNER JOIN Placements ON PCC_Vendor_Number.PCC_VNum = Placements.PCC_VNum) INNER JOIN Client ON Placements.CRPCaseNum = Client.CRPCaseNum
WHERE (((Placements.datDischarge)>=DateAdd("m",-15,DateSerial(Year(Date()),Month(Date()),1)) Or (Placements.datDischarge) Is Null) AND ((Placements.datAdmit)<DateAdd("m",-15,DateSerial(Year(Date()),Month(Date()),1))))
GROUP BY PCC_Vendor_Number.PCC_VNum, Placements.CRPCaseNum
ORDER BY PCC_Vendor_Number.PCC_VNum;