
Write a PostgreSQL query that reconciles March 2024 program costs between an ERP source and a plant reporting source. Return only programs where the two sources do not balance, along with both totals, the absolute variance, and a status showing whether the issue is a missing source or a mismatch.
| Column | Type | Description |
|---|---|---|
| program_id | ||
| program_code | ||
| platform_name |
| Column | Type | Description |
|---|---|---|
| cost_id | ||
| program_id | ||
| posting_date | ||
| cost_type | ||
| amount |
| Column | Type | Description |
|---|---|---|
| plant_entry_id | ||
| program_code | ||
| report_month | ||
| amount |
One row per program_codeMarch 2024 ERP and plant totalsAbsolute variance between sourcesStatus label: Missing Source or MismatchExclude balanced programs