Block interview question

Aggregate query