Next Insurance interview question

Sql need groupby, windows function etc