Reputation: 51
I have a date column I need to do date difference with previous row date using hive query?
Upvotes: 0
Views: 92
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