Tharun Audhimoolam
Tharun Audhimoolam

Reputation: 51

How to do date difference with previous row date using hiveql?

I have a date column I need to do date difference with previous row date using hive query?

Upvotes: 0

Views: 92

Answers (1)

Vijiy
Vijiy

Reputation: 1197

Below would be the query -

select date, datediff(date, prev_date) from (select date, lag(date) over (partition by <colName> order by <Name>) as prev_date from tableName) t1;

If you can provide the sample data with tableName Can help you with the exact query

Upvotes: 1

Related Questions