Write a SQL query to identify stores with declining inventory turnover over the last 3 months, including month-over-month change and rank by decline severity.
Use the provided store, inventory, and sales data. Include only stores with valid turnover values for all three months and decreases in both month-over-month comparisons.
Output
- One row per qualifying store.
- Columns:
store_id, store_name, first_month_turnover, latest_month_turnover, first_mom_change, second_mom_change, latest_mom_change, total_decline, and decline_rank.
- Rank stores by
total_decline descending, with lower store_id breaking ties.