How would you write a query using LEAD, LAG, RANK, and rolling averages for time-series financial data?