I have a table with 4 columns. The excel sheet is here: https://docs.google.com/spreadsheets/d/1xzsFZ43iuyAe2gLfq7ZVTmymrwi8Qr_2/edit?usp=sharing&ouid=116133872634893383506&rtpof=true&sd=true I am trying to compute a calculated column by taking values from payment column based on date column. In my payment column I have zeors in between the values. When I will calculate the previous payment amount, it will calculate in way that It will check date column at first, if the date is previous date of current date then it will check the payment value last month's date and will take repayment value. but if there is 0 in payment column it will look for what is first non null or non zeros value in previous month and then will take it. I tried it in this way but not working. I am writing it in Hadoop's impala
select id,event_date, Date,
coalesce(lagged_payment, last_value(lagged_payment) over (Order by Date Rows between unbounded preceding and current row)) as previous_rental
from (
select id, event_date, Date,
lag(payment) OVER (ORDER BY Date) as lagged_payment)ad