当我在Access 2016中运行下面的代码时,我在子查询之间得到0匹配。但是,如果我从顶部子查询中删除销售日期字段,或者从两者中删除,我会得到正确的匹配项。我当然不是SQL专家,但这看起来很奇怪,让我疯了几个小时。任何人都可以解释为什么会出现这种情况吗?
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]