Lark interview question

A pretty complex SQL query