Write a SQL query to analyze operational performance by CRH site, including monthly output, defect rate, and year-over-year change. Use the provided CRH site, production batch, and inspection data. Include months with production records, handle missing inspection data and zero output safely, and compare each month with the same month in the prior year.
Output
- One row per CRH site and production month.
- Columns:
site_code, month, monthly_output, defect_rate, and yoy_output_change_pct.
- Sort by
site_code, then month ascending. Return NULL when a prior-year comparison or valid defect-rate denominator is unavailable.