How would you handle a situation where your data gets corrupted while working on the analysis? What method or alternative would you use?
Write a PostgreSQL query that compares analysis data with a trusted snapshot, flags discrepancies, and selects a trusted value or backup value when available.
record_id ascendingrecord_id, analysis_date, current_metric, data_status, selected_metricVALID, CORRUPTED, or UNVERIFIED; use the trusted metric when available, otherwise the backup metric, otherwise the current metric| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Identifier for the analysis record |
| analysis_date | DATE | Date associated with the analysis record |
| metric_value | DECIMAL(10,2) | Metric value currently used in the analysis |
| source_batch | VARCHAR(30) | Batch that produced the current analysis value |
| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Identifier corresponding to an analysis record |
| metric_value | DECIMAL(10,2) | Metric value from the trusted snapshot |
| snapshot_status | VARCHAR(20) | Status of the trusted snapshot row |
| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Identifier corresponding to an analysis record |
| metric_value | DECIMAL(10,2) | Metric value from the backup source |
| backup_status | VARCHAR(20) | Status of the backup row |