gaojian

create table  test(id integer);

insert into test values(1);

insert into test values(3);

insert into test values(6);

insert into test values(10);

insert into test values(15);

insert into test values(24);

------------------------------------------

select id, lag(id, 1,0) from test;

id     lag

1      0

3      1 

6      3

10     6

15    10

24    15

------------------------------------------ 

select id, lag(id, 2,0) from test;

id     lag

1      0

3      0 

6      1

10     3

15    6

24    10

------------------------------------------ 

select id, lag(id, 1,1) from test;

id     lag

1      1

3      1 

6      3

10     6

15    10

24    15

------------------------------------------ 

select id, lag(id, 2,1) from test;

id     lag

1      1

3      1 

6      1

10     3

15    6

24    10

分类:

技术点:

相关文章:

  • 2021-08-05
  • 2021-08-05
  • 2021-08-05
  • 2021-09-08
  • 2021-08-05
  • 2021-08-05
  • 2021-08-05
  • 2021-08-05
猜你喜欢
  • 2021-08-05
  • 2021-08-05
  • 2021-08-05
  • 2021-08-05
  • 2021-08-05
  • 2021-08-05
  • 2021-08-05
相关资源
相似解决方案