Write a SQL query to identify the top three departments with the highest equipment preventive maintenance delays over the last quarter at Advanced Micro Devices.
Use the provided department, equipment, and maintenance work order data. Count only preventive work orders scheduled during the previous calendar quarter, completed after their scheduled date, and with a non-null completion date.
Output
- One row per department, with
department_name, total_delay_days, and delayed_work_orders
- Return the three highest totals, ordered by
total_delay_days descending, then delayed_work_orders descending, then department_name ascending