表格1
START END rownum
1 1 1
2 3 2
4 7 3
8 8 4
9 9 5
表 2
START END rownum
1 1 1
2 3 2
4 7 3
8 8 4
9 9 5
询问:
SELECT TB1.START,TB1.[END],TB1.rownum as row_1,TB2.START,TB2.[END],TB2.rownum as row_2 FROM
(
select START,[END],ROW_NUMBER() over(order by import_num) as rownum from
table1
) TB1
INNER JOIN
(
select START,[END],ROW_NUMBER() over(order by import_num) as rownum from
table1
) TB2
ON TB1.rownum + 1 = TB2.rownum
结果:
START END row_1 START END row_2
1 1 1 2 3 2
2 3 2 4 7 3
4 7 3 8 8 4
8 8 4 9 9 5
问题:
当我的加入条件为 tb1.rownum + 1 时,为什么 rownum 会指示-1,2,3,4?不应该是2,3,4,5吗