【问题标题】:Wrong number of arguments SQL MSACCESS参数数量错误 SQL MS ACCESS
【发布时间】:2014-01-08 13:14:07
【问题描述】:

当我运行以下查询时,我收到一个错误,指出参数数量错误:

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;

谁能建议我如何解决这个问题?

我也试过下面的代码:

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;

还有这段代码:

     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;

【问题讨论】:

标签: sql ms-access ms-access-2007


【解决方案1】:

Exp需要一个参数,你给两个。

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

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

【讨论】:

    【解决方案2】:

    尝试替换...

    EXP(<expression>, 2)
    

    ...到...

    <expression>^2
    

    在 Access 中,EXP 函数返回 e(自然对数的底)的幂。要将表达式提升到幂,请使用 ^ 运算符。

    在您的情况下,请注意在表达式周围加上括号,例如...

    (population_postcodes.longitude- target_postcodes.longitude)^2
    

    ...强制最后施加电源。默认情况下,^ 运算符在 - 运算符之前计算。

    【讨论】:

    • 亲爱的布赖恩感谢您的帮助,但它仍然无法正常工作。这是我当前的查询: 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 ) 作为距离;
    • 尝试将distance 表达式移动到SELECT 子句,例如: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;
    • 由于某种原因,它仍然会产生一个空表,其中创建的列名代表表名及其所有列以及一个新的距离列...
    • 那么Population_postcodes 中的任何记录都必须没有Population_postcode 等于Target_postcodes 中任何记录的Target_postcode
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多