Domanda di colloquio di OP-Pohjola

How would you write this in SQL