ezoic

Thursday, October 27, 2016

How to get the difference between one row and next row for one column in netezza

I am using Netezza for windows. And I tried to get the get the difference between one row and next row  for one column.

I found the function LAG and LEAD.

Here is the query:

select extract(epoch from a.day_id) - extract(epoch from a.lag1) as diff1,day_id from (
select day_id, lag((day_id),1, null) over (order by day_id) as lag1 from table1 where day_id is not null group by day_id ;

No comments:

Post a Comment

looking for a man

 I am a mid aged woman. I live in southern california.  I was born in 1980. I do not have any kid. no compliacted dating.  I am looking for ...