【发布时间】:2014-04-01 10:05:45
【问题描述】:
在选择查询中,我使用嵌套选择计算字段。我想按计算字段(排名)对结果进行排序,但是 Access 无法识别字段排名。 (当我运行查询时,Access 会要求提供 rank 的参数值。)
SELECT
*,
(select count(*)
from tbl as tbl2
where tbl.customers > tbl2.customers and tbl.dept = tbl2.dept
) + 1 as rank
FROM tbl
ORDER BY rank
[示例查询取自thispost]
【问题讨论】:
-
能不能先做子查询,再
, *,再ORDER BY 1? -
我尝试重新排列和
ORDER BY 1,但这没有任何效果。