如何从teradata中的当前行值中减去所有先前的行值?

时间:2016-10-22 13:39:22

标签: teradata

如何从teradata中的当前行值中减去所有先前的行值? column Value不是整数格式。

1 个答案:

答案 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