[英]Why am I getting “Enter Parameter Value” when running my MS Access query?
In my query, I use the IIF
function to assign either "Before" or "After" to a field named BeforeOrAfter
using AS
. 在我的查询中,我使用IIF
函数将“之前”或“之后”分配给使用AS
名为BeforeOrAfter
的字段。
When I run this query, however, the "Enter Parameter Value" dialog appears, requesting a value for BeforeOrAfter
. 但是,当我运行此查询时,会出现“输入参数值”对话框,请求BeforeOrAfter
的值。 If I remove BeforeOrAfter DESC
from the ORDER BY
clause, I don't get the dialog. 如果我从ORDER BY
子句中删除BeforeOrAfter DESC
,我没有得到对话框。
Here is the offending query: 这是有问题的查询:
SELECT
d.Scenario,
e.Event,
IIF(d.LogTime < e.Time, 'Before','After') AS BeforeOrAfter,
d.HeartRate
FROM
Data d INNER JOIN
Events e ON d.Scenario = e.Scenario
WHERE
e.Include = Yes
ORDER BY
d.Scenario,
e.Id,
BeforeOrAfter DESC
Question: Why is my AS BeforeOrAfter
not being recognized by the ORDER BY
clause? 问题:为什么我的AS BeforeOrAfter
不被ORDER BY
子句识别? Why does it ask me to enter a parameter value for "BeforeOrAfter" when I run this query? 为什么我在运行此查询时要求我输入“BeforeOrAfter”的参数值?
Note: I tried using brackets, single quotes, double quotes, etc., but none of that made any difference. 注意:我尝试使用括号,单引号,双引号等,但这些都没有任何区别。
I beleive Access can't handle the alias feature, so you'll have to copy your IIF-block down into the Order By -clause. 我相信Access无法处理别名功能,因此您必须将IIF块复制到Order By -clause中。 Or create a subquery (and then you might even find yourself forced to even not be able to use parantheses if your Access version isn't among the newest two or so). 或者创建一个子查询(如果你的Access版本不是最新的两个左右,你甚至可能发现自己甚至不能使用parantheses)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.