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

查看:92
本文介绍了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天全站免登陆