我正在为我们的会计部门做一个项目,我遇到了下面的问题。我们在MSAccess DB中有两个表,其中包含税务数据。这个过程是我们每月收到一个包含新税务信息的文件。数据更改的唯一时间是进行税务更新,而不是政府实体。因此,在任何给定的月份,我们可以有5次更改或5000次更改。
下面查询的目标是将新数据与上个月的数据(在两个单独的表中)进行比较。但是,系统提示我输入条件,但我不确定原因。理想情况下,查询将运行并返回两个表之间的任何差异。
SELECT newtax.[zipcode],
newtax.city,
newtax.county,
newtax.state,
newtax!combinedsalestax - oldtax!combinedsalestax AS Change,
newtax.combinedsalestax,
oldtax.combinedsalestax
FROM oldtax
INNER JOIN newtax
ON ( oldtax.[zipcode] = newtax.[zipcode] )
AND ( oldtax.city = newtax.city )
AND ( oldtax.county = newtax.county )
WHERE (( ( [newtax]![combinedsalestax] - [oldtax]![combinedsalestax] ) <> 0)); 我也对如何完全修改这个查询的建议持开放态度,因为我假设有更好的方法。提前感谢!
发布于 2013-02-02 06:44:05
你应该去掉感叹号,它们是控件,而不是字段。检查null (Nz)可能是个好主意。
SELECT newtax.[zipcode],
newtax.city,
newtax.county,
newtax.state,
newtax.combinedsalestax - oldtax.combinedsalestax AS Change,
newtax.combinedsalestax,
oldtax.combinedsalestax
FROM oldtax
INNER JOIN newtax
ON ( oldtax.[zipcode] = newtax.[zipcode] )
AND ( oldtax.city = newtax.city )
AND ( oldtax.county = newtax.county )
WHERE Nz(newtax.combinedsalestax,0) <> Nz(oldtax.combinedsalestax,0) 如果仍提示您输入参数,则可能是字段名称拼写错误。
https://stackoverflow.com/questions/14656105
复制相似问题