以下是用 ORACLE 编写的查询,用于给出前一行,最后给出输出。如何在 MS Access 中特别是 ROWNUM 部分中的 ORACLE 查询下方构建框架。感谢您的输入
orcl> WITH d
2 AS (SELECT ROWNUM rn,
3 dname,
4 deptno
5 FROM (SELECT dname,
6 deptno
7 FROM dept
8 ORDER BY dname)),
9 e
10 AS (SELECT ROWNUM + 1 rn,
11 dname,
12 deptno
13 FROM (SELECT dname,
14 deptno
15 FROM dept
16 ORDER BY dname))
17 SELECT rn,
18 d.dname,
19 d.deptno this_row,
20 e.deptno previous_row
21 FROM d
22 left outer join e USING (rn)
23 ORDER BY dname;
RN DNAME THIS_ROW previous_ROW
1 ACCOUNTING 10
2 OPERATIONS 40 10
3 RESEARCH 20 40
4 SALES 30 20