Walk me through a complex SQL query you wrote to solve a difficult business problem. What joins and functions did you use?