When I run the code below in Access 2016, I get 0 matches between the subqueries. However, if I remove the Date of Sale Field from the top subquery or from both I get correct matches. I'm certainly not a SQL expert but this seems really odd and drove me crazy for a couple of hours. Can anyone shed some light on why this might be the case?
select count(1) from
(select t1.[customer number], [date of sale],count(1) from 6mototal t1,
6molkp t2
where t1.[customer number]=t2.[customer number]
and mnth=(select distinct(month(DateAdd ('m', -4, firstdate))) from 6molkp)
group by [date of sale],t1.[customer number]
) t5,
(select t1.[customer number],[date of sale],count(1) from 6mototal t1,
6molkp t2
where t1.[customer number]=t2.[customer number]
and mnth=(select distinct(month(DateAdd ('m', -5, firstdate))) from 6molkp)
group by [date of sale],t1.[customer number]
) t6
where t5.[customer number]=t6.[customer number]