如何从teradata中的当前行值中减去所有先前的行值? column Value不是整数格式。
答案 0 :(得分:0)
您应该学习Teradata OLAP函数..并尝试以下: -
select COL1,COL2 ,
coalesce(min(col2) over (partition by col1 order by col2 rows between 1 preceding and 1 preceding), 0) as prv_value
col2-prv_value as diff
from TEMP