我有以下ms访问查询,它会报告左表中的所有记录。但是,只要我在右表的select语句中有一列,那么记录开始增加的数量超过了左表中的最大记录
有人可以帮助我如何改变代码,这样它就可以让我从右侧表中包含字段,同时保持最大记录输出为左表中的总记录而不是其他
SELECT BENEFITS_FORECAST2.lob, BENEFITS_FORECAST2.period,
BENEFITS_FORECAST2.rd_aflc_f,
(BENEFITS_FORECAST2.ils_aflc_f-ils_aflc_a) AS ils_aflc_v
FROM BENEFITS_FORECAST2 left join Benefits_mom_data_set1 ON (BENEFITS_FORECAST2.LOB = Benefits_mom_data_set1.BenefitsLOB) AND (BENEFITS_FORECAST2.PERIOD = Benefits_mom_data_set1.Period)
WHERE (((Benefits_mom_data_set1.newCnt)=1) AND ((Benefits_mom_data_set1.legalServiceProviderType) Like 'on panel'))
group by BENEFITS_FORECAST2.lob, BENEFITS_FORECAST2.period, BENEFITS_FORECAST2.rd_aflc_f
order by BENEFITS_FORECAST2.lob, BENEFITS_FORECAST2.period
答案 0 :(得分:0)
你能在两张桌子上分享一些数据吗?
从右侧添加列不应增加正常左连接中左侧的记录数。
但是,我注意到你有一个GROUP BY
条款。如果您没有使用Benefits_mom_data_set1中的其他列正确分组,那么您可能会获得多行。