What is your approach to ensuring data integrity in high-stakes environments like compensation or workplace tech?
Write a PostgreSQL query that audits compensation changes against employee and approval records. Identify every integrity finding in the supplied data, including missing employee references, invalid salary amounts, duplicate effective dates, missing or improperly timed submission dates, salary decreases, and changes without an approved approval.
Output
- One row per detected finding, with
employee_id, employee_name, change_id, effective_date, salary_amount, approval_status, and issue_code.
- Include only records with a finding. Rows with NULL employee names may appear when the employee reference is missing.
- Sort by employee ID, change ID, and a logical issue priority.