Loading...
Loading...
You are working as a data analyst for an insurance company. The risk management team wants to flag policyholders who are filing claims at an unusually high rate, as these individuals may need further review.
Write a SQL query to identify all policyholders who have submitted more than 3 claims within the last 12 months (relative to today's date). Return their policyholder ID, full name, and the total number of claims filed in that period.
policyholders| Column | Type | Description |
|---|---|---|
id | INT | Primary key |
name | VARCHAR | Full name |
email | VARCHAR | Email address |
claims| Column | Type | Description |
|---|---|---|
id | INT | Primary key |
policyholder_id | INT | Foreign key to policyholders |
claim_date | DATE | Date the claim was filed |
amount | DECIMAL | Claim amount in USD |
status | VARCHAR | 'approved', 'pending', or 'rejected' |
Return a result set with columns:
policyholder_id — the ID of the policyholdername — the full name of the policyholdertotal_claims — count of claims filed in the last 12 monthsOrder the results by total_claims descending, then by policyholder_id ascending.
claim_date >= CURRENT_DATE - INTERVAL '12 months' (or equivalent in your SQL dialect)COUNT > 3)policyholder_idWHERE clause with a date range condition- 1 <= number of policyholders <= 10^6 - 0 <= number of claims per policyholder <= 10^4 - claim_date is a valid DATE in the past or present - All policyholder_id values in claims reference an existing policyholder - amount >= 0 - status is one of: 'approved', 'pending', 'rejected'