Wrong number of arguments SQL MSACCESS

情到浓时终转凉″ 提交于 2019-12-11 10:32:44

问题


I am getting an error indicating the wrong number of arguments when I run the following query:

SELECT
population_postcodes.*, 
target_postcodes.*, 
SQR( EXP(population_postcodes.longitude- target_postcodes.longitude, 2) + EXP(population_postcodes.latitude-target_postcodes.latitude, 2) ) as distance
FROM population_postcodes INNER JOIN target_postcodes on Population_postcodes.Population_postcode = Target_postcodes.Target_postcode;

Could anyone please suggest how I can fix this?

I have also tried the following code:

SELECT Population_postcodes.*, Target_postcodes.* 

FROM population_postcodes
INNER JOIN target_postcodes
ON Population_postcodes.Population_postcode = Target_postcodes.Target_postcode
SQR( (population_postcodes.longitude- target_postcodes.longitude)^2 + (population_postcodes.latitude-target_postcodes.latitude)^2 ) as distance;

And this code:

     SELECT Population_postcodes.*, Target_postcodes.*, SQR( (population_postcodes.longitude- target_postcodes.longitude)^2 + (population_postcodes.latitude-target_postcodes.latitude)^2 ) as distance
FROM population_postcodes
INNER JOIN target_postcodes
ON Population_postcodes.Population_postcode = Target_postcodes.Target_postcode;

回答1:


Exp needs one parameter, you give two.

Old: EXP(population_postcodes.longitude- target_postcodes.longitude, 2)

New: (population_postcodes.longitude- target_postcodes.longitude)*(population_postcodes.longitude- target_postcodes.longitude)




回答2:


Try replacing...

EXP(<expression>, 2)

...to...

<expression>^2

In Access, the EXP function returns e (the base of natural logarithms) raised to a power. To raise an expression to a power, use the ^ operator.

In your case, be careful to put brackets around the expression, for example...

(population_postcodes.longitude- target_postcodes.longitude)^2

...to force the power to be applied last. By default, the ^ operator is evaluated before the - operator.



来源:https://stackoverflow.com/questions/20996713/wrong-number-of-arguments-sql-msaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!