本文介绍了请给我查询波纹管所需的输出。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Query to make a separate column to differentiate over by over difference?
create table test1(overs int,runs int)
insert into test1 values(1,10)
insert into test1 values(2,17)
insert into test1 values(3,20)
insert into test1 values (4,32)
insert into test1 values(5,38)
O/P
===
Overs runs difference
1 10 NULL
2 17 7
3 20 3
4 32 12
5 38 6
What I have tried:
please any one give me the Query to achieve this above Requirement.
推荐答案
SELECT Overs, Runs, Runs - LAG(Runs, 1, NULL) OVER (ORDER BY Overs) AS [Difference] FROM test1
这篇关于请给我查询波纹管所需的输出。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!