MS-Access ->SELECT AS + ORDER BY = 错误 [英] MS-Access -> SELECT AS + ORDER BY = error

查看:41
本文介绍了MS-Access ->SELECT AS + ORDER BY = 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查询以检索甜食销量最高的地区.'grupo_produto' 是产品类型,'regiao' 是区域.所以我得到了这个查询:

I'm trying to make a query to retrieve the region which got the most sales for sweet products. 'grupo_produto' is the product type, and 'regiao' is the region. So I got this query:

SELECT TOP 1 r.nm_regiao,  (SELECT COUNT(*)
        FROM Dw_Empresa
        WHERE grupo_produto='1' AND 
        cod_regiao = d.cod_regiao) as total 
FROM Dw_Empresa d
INNER JOIN tb_regiao r ON r.cod_regiao = d.cod_regiao ORDER BY total DESC

然后,当我运行查询时,MS-Access 要求提供total"参数.为什么它不考虑我在 select 子句中创建的新创建的列"?

Then when i run the query, MS-Access asks for the "total" parameter. Why it doesn't consider the newly created 'column' I made in the select clause?

提前致谢!

推荐答案

别名只能在查询输出中使用.您不能在查询的其他部分使用它们.不幸的是,您必须复制并粘贴整个子查询才能使其工作.

Aliases are only usable in the query output. You can't use them in other parts of the query. Unfortunately, you'll have to copy and paste the entire subquery to make it work.

这篇关于MS-Access ->SELECT AS + ORDER BY = 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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