I got the exactly same error message and logs in db2diag.log, what I did to solve this issue is don't do the roll forwarding after the restore, must keep the restored DB in roll forwarding pending status, then you can start HADR on it.
It's always good to provide sample data as insert statements along with create table statements. Now, the following is completely untested:
SELECT cust_id, SUM(paid_amt) as paid_amt, pd_date
SELECT cust_id, paid_amt, pd_date
, RANK() OVER (PARTITION BY cust_id
ORDER BY pd_date desc) AS rnk
WHERE rnk = ...
I think this can be solved by using a CTE for each of the two selects.
I created an example for you by joining the tables SYSIMB.TABLES and SYSIBM.VIEWS. From both I fetch the first 5 rows only.
FIRST 5 rows ...
You must connect to the database first to change some parameter online, if it's possible for this parameter:
db2 connect to CMNDB
db2 update db cfg using AUTO_DEL_REC_OBJ ON
db2 get db cfg show detail | grep AUTO_DEL_REC_OBJ