子查询访问中无法识别表别名

时间:2019-10-23 14:56:29

标签: sql ms-access

我创建了一个查询以查找具有匹配ID标准的上一行。在WHERE语句中,我的表别名“ t1”未被识别为别名,并且在运行查询时,系统提示我输入T1的参数值。据我了解,子查询必须具有表别名。如何使“输入参数值”提示消失?我的SQL代码如下。

SELECT t.NUM, t.ID, tprev.Date_ AS previous_date, tprev.Measurement AS previous_measurement
FROM Table1 AS t LEFT JOIN Table1 AS tprev ON (tprev.Date_ < t.Date_) AND (tprev.id = t.id)
WHERE not exists 
        (select 1
        from Table1 AS t1
        where 
            t1 = t.ID
            and t1.Date_ < t.Date_
            and t1.Date_ > tprev.Date_);

1 个答案:

答案 0 :(得分:1)

您有一个表别名,但没有列。想必您打算:

where not exists (select 1
                  from Table1 AS t1
                  where t1.ID = t.ID and
--------------------------^ this part
                        t1.Date_ < t.Date_ and
                        t1.Date_ > tprev.Date_
                 );