Microsoft Access 中的滞后函数(Window 函数)

Lag function in Microsoft Access (Window Function)

如何在 Microsoft Access 中使用 Window 函数。这是我的查询片段。

SELECT [OutTest]![CoSerNum] AS CoSerNum, lag([OutTest]![CoSerNum] ,1) over(order by [OutTest]![CoSerNum] ) 
FROM OutTest
WHERE (((OutTest.SO)=[Enter SO]));

谁能帮我解决 MS Access 中的查询问题。

Access 不支持 window 函数。在这里,您可以使用相关子查询来模拟它:

SELECT 
    ot.[CoSerNum] AS CoSerNum, 
    (SELECT MAX(ot.[CoSerNum]) FROM OutTest ot1 WHERE ot1.[CoSerNum] < ot.[CoSerNum]) AS lagCoSerNum  
FROM OutTest ot
WHERE ot.SO = [Enter SO];