Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to append the preceding rows for the same key for different dates in hive

Highlighted

How to append the preceding rows for the same key for different dates in hive

New Contributor

I have a scenario like below. can anyone please provide some info.

 

I have the below table. i tried doing this using join with lag and lead function but its not giving the expected result. I'm just not getting any clue how to implement the solution for this.

Input table

 

name date amount
abc 04/06/2018 100
abc 04/06/2018 200
abc 04/13/2018 300 


now the output i needed is below.

 

name date amount
abc 04/06/2018 100
abc 04/06/2018 200
abc 04/13/2018 100
abc 04/13/2018 200
abc 04/13/2018 300


so here 300 is the new value for 04/13/2018 and 100,200 from 04/06/2018 will also shown for 04/13/2018.

Do we have any way to do this in hive. Any help will be greatly appreciated.