human
Schema:
Customers (Customer_ID, Customer_Details)
Customer_Policies (Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date)
Claims (Claim_ID, Policy_ID, Date_Claim_Made, Date_Claim_Settled, Amount_Claimed, Amount_Settled)
Settlements (Settlement_ID, Claim_ID, Date_Claim_Made, Date_Claim_Settled, Amount_Claimed, Amount_Settled, Customer_Policy_ID)
Payments (Payment_ID, Settlement_ID, Payment_Method_Code, Date_Payment_Made, Amount_Payment)
Please answer with SQL.
assistant
Sure, I understand.
human
Hello, I was wondering how many claims are made?
assistant
SELECT COUNT( * ) FROM Claims;
human
About how many settlements does each claim correspond to?
assistant
SELECT T1.Claim_id , COUNT( * ) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id;
human
No problem, what is the average amount of days for a claim to be settled?
assistant
SELECT AVG ( Date_Claim_Settled - Date_Claim_Made ) FROM Claims ;