Write a SQL query to identify facilities with declining output over the last 4 weeks using window functions.
Use the provided facility and weekly output data. Include only facilities with output recorded for all four weeks, where each week's output is strictly lower than the preceding week.
facility_id, facility_name, week_1_output, week_2_output, week_3_output, week_4_output, and decline_weeks.week_1_output is the latest week, and week_4_output is the oldest.facility_id ascending.| Column | Type | Description |
|---|---|---|
| facility_idPK | INT | Unique facility identifier |
| facility_name | VARCHAR(100) | Facility name |
| Column | Type | Description |
|---|---|---|
| output_idPK | INT | Unique weekly output record identifier |
| facility_id | INT | Facility associated with the output record |
| week_start | DATE | Start date of the reporting week |
| output_units | INT | Units produced during the week |