How would you solve a moderate-level SQL problem involving joins, window functions, and aggregations?