Write a SQL query using window functions to find the top three selling automotive parts in each store category for the last quarter at Advance Auto Parts.
Use the provided store, part, and sales data. Treat the last quarter as the complete calendar quarter immediately before the current quarter. Return only parts with sales during that period.
Output
- One row per qualifying part, with
store_category, part_id, part_name, total_units_sold, and sales_rank.
- Include the top three parts in each category, ranked by total units sold descending.
- Break ties by
part_id ascending, and order the final results by store_category, sales_rank, and part_id.