UBS Interview Question

SQl query question