Persistent Systems Interview Question

Sql query