Need Help to implement recursive logic

Database

Need Help to implement recursive logic

I have  tow  tables  say A  and B which is  having  date  field  and  amount  field  respectively. Have  to  check  whether a.date > b.date  if  yes  then  check  a.amount > b.amount  if  yes  then   do  a.amt - b.amt  until  we  get  a.amount < b.amount (basically create  mutliple  rows)

ex: a. amount ---2000

b.amount is  200

1st row   -----2000

2nd row-----2000-200=1800

3rd  row--1600

....10th  row --0

1 REPLY
Junior Contributor

Re: Need Help to implement recursive logic

It's hard to tell without more details, DDL, some INSERTs and the expected result.

You can probably do that using WITH RECURSIVE or maybe EXPAND ON in TD13.10 

Dieter