我想将范围计算为row1-row2,在db2查询中需要帮助以获取范围列
name,age,range
a,40,0
b,20,20
c,7,13
d,5,2
e,1,4
范围列计算
first value is 0
(40-20)
(20-7)
(7-5)
(5-1)
答案 0 :(得分:2)
SELECT name,
age,
(lag(age, 1, age) over (order by age desc)) - age as agediff
FROM your_table
ORDER BY age desc