Hey Jan,
It looks like a puzzle or test question to me, so there may not be a real requirement at all 🙂
Jack's solution seems to cover the key points, so my guess would be that PHK has his answer.
Which is nice 😉
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi