Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have data like below:

id	merchant_enrolled_program_id	point	current_balance	Expected RESULT
7499475	23140	-111634	288636	288636
7499601	23140	-266593	288636	22043
7500024	23140	1500000	288636	1522043
7500059	23140	-74314	288636	1447729
7500191	23140	-14049	288636	1433680


I want to take first current_balance (288636) plus second rows point (-266593) and expected result will populate in current_balance columns in second row

as I have given the expected result too.

What I have tried:

select 
coalesce(at.current_balance+(select sum(a1.point) from akshaya_temp a1
where a1.id <at.id and a1.merchant_enrolled_program_id=at.merchant_enrolled_program_id order by a1.id limit 1,1),at.current_balance) 
into v_current_balance 
from akshaya_temp at where at.id=v_ID and at.merchant_enrolled_program_id= v_merchant_enrolled_program_id;
Posted
Updated 14-Mar-23 1:39am
v3

1 solution

 
Share this answer
 
Comments
Member 15950667 14-Mar-23 7:16am    
not supporting LEAD() and LAG()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900