Allianz Interview Question

Db2 cursor, rules, complex queriea