OP-Pohjola Interview Question

How would you write this in SQL