I have a table that has data looks like:
| date | qlfd_lvl | actv_ind | last_value |
|---|---|---|---|
| 20230301 | 4 | 1 | 4 |
| 20230302 | 2 | 1 | 2 |
| 20230303 | 3 | 0 | 2 |
| 20230304 | 1 | 0 | 2 |
| 20230305 | 3 | 1 | 3 |
| 20230306 | 2 | 0 | 3 |
| 20230307 | 1 | 0 | 3 |
we have 2 conditions for column last_value 1.condition: actv_ind=1 then the results will same campaign qlfd_lvl value. 2.condition: actv_ind=0 then results will when previous actv_ind=1 then it will take that date qlfd_lvl value as results
(in snowflake SQL I have tried LAG and last_value but I didn't get logic )