简体   繁体   中英

Wrong number of arguments SQL MSACCESS

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;

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM