为什么此查询需要参数? [英] Why does this query require a parameter?

查看:94
本文介绍了为什么此查询需要参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MS Access中有以下SQL查询.我正在尝试通过标记为响应"的列中包含的表达式的结果对输出进行排序.我的问题是,当我运行查询时,Access提示我输入Response的参数值.我尝试输入零和一来查看会发生什么.在这种情况下查询将运行,但是排序顺序是错误的.有人可以向我解释为什么这个查询需要一个参数吗?我在做错什么吗?

I have the following SQL query in MS Access. I'm trying to order the output by the results of an expression contained in the column labeled as 'Response'. My problem is that when I run the query Access prompts me to enter a parameter value for Response. I tried entering zero and one to see what would happen. The query runs in those cases but the sort order is wrong. Can someone please explain to me why this query would require a parameter? Am I doing something wrong?

SELECT Market,
       Sum(Calls) AS SumOfCalls,
       Sum([A25-54 IMPs] * 1000) AS Impressions,
       Round(SumOfCalls/Impressions, 6) AS Response
FROM DRTV_CentralOnly
WHERE [Creative]<>'#N/A'
GROUP BY Market
ORDER BY Response Desc;

推荐答案

它不需要参数.问题是您在Response列之一中使用了列别名.您需要使用实际的计算来代替.

It is not requiring a parameter. The problem is that you are using columns aliases in one your Response column. You need to use the actual calculations instead.

SELECT Market
    , Sum(Calls) AS SumOfCalls
    , Sum([A25-54 IMPs] * 1000) AS Impressions
    , Round(Sum(Calls)/Sum([A25-54 IMPs] * 1000), 6) AS Response
FROM DRTV_CentralOnly
WHERE [Creative]<>'#N/A'
GROUP BY Market
ORDER BY 4 Desc;

这篇关于为什么此查询需要参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆