Given a specific data table, calculate the expected output based on a set of conditional business rules.
Write a PostgreSQL query using data_records and conditional_rules. Apply the listed amount ranges and return the calculated decision and adjusted amount for every record, including records with no matching rule.
record_id, category, amount, decision, and adjusted_amount.REVIEW; negative amounts are INVALID with an adjusted amount of zero; unmatched non-null values are UNCLASSIFIED and retain their amount.record_id ascending.| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Unique identifier for the source record |
| category | VARCHAR(20) | Category used to select a conditional rule |
| amount | DECIMAL(10,2) | Value evaluated against the rule range |
| Column | Type | Description |
|---|---|---|
| rule_idPK | INT | Unique identifier for the conditional rule |
| category | VARCHAR(20) | Category to which the rule applies |
| min_amount | DECIMAL(10,2) | Inclusive lower boundary for the rule |
| max_amount | DECIMAL(10,2) | Exclusive upper boundary for the rule |
| outcome | VARCHAR(20) | Decision returned when the rule matches |
| multiplier | DECIMAL(5,2) | Factor applied to the source amount |