Apache Tajo - lag (value, offset, default)



Let us now check the lag(value,offset,default) function with the following query.

Query

sampledb> select lag(mark,3,2) over (partition by age) as lagvalue from mytable;   

Result

The above query will generate the following result.

lagvalue 
------------------------------- 
2 
2 
2 
90 
80 
85 
55 
60 
2 
2 

The query returns the value evaluated at the row that is offset rows before the current row within the partition. Whenever the rows are not matching, then the given default value 2 is replaced.

apache_tajo_aggregate_and_window_functions.htm
Advertisements