Allianz interview question

Db2 cursor, rules, complex queriea