CREATE TABLE Customers (
    Customer_ID NUMBER PRIMARY KEY,
    Customer_Details TEXT
);
CREATE TABLE Customer_Policies (
    Policy_ID NUMBER PRIMARY KEY,
    Customer_ID NUMBER,
    Policy_Type_Code TEXT,
    Start_Date TIME,
    End_Date TIME,
    FOREIGN KEY ("Customer_ID") REFERENCES Customers("Customer_ID")
);
CREATE TABLE Claims (
    Claim_ID NUMBER PRIMARY KEY,
    Policy_ID NUMBER,
    Date_Claim_Made TIME,
    Date_Claim_Settled TIME,
    Amount_Claimed NUMBER,
    Amount_Settled NUMBER,
    FOREIGN KEY ("Policy_ID") REFERENCES Customer_Policies("Policy_ID")
);
CREATE TABLE Settlements (
    Settlement_ID NUMBER PRIMARY KEY,
    Claim_ID NUMBER,
    Date_Claim_Made TIME,
    Date_Claim_Settled TIME,
    Amount_Claimed NUMBER,
    Amount_Settled NUMBER,
    Customer_Policy_ID NUMBER,
    FOREIGN KEY ("Claim_ID") REFERENCES Claims("Claim_ID")
);
CREATE TABLE Payments (
    Payment_ID NUMBER PRIMARY KEY,
    Settlement_ID NUMBER,
    Payment_Method_Code TEXT,
    Date_Payment_Made TIME,
    Amount_Payment NUMBER,
    FOREIGN KEY ("Settlement_ID") REFERENCES Settlements("Settlement_ID")
);

Question: Who are the customers that had more than 1 policy? List the customer details and id.
SQL: SELECT T1.customer_details ,  T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id  =  T2.Customer_id GROUP BY T1.customer_id HAVING count(*)  >  1

Question: Find the the customer details and id for the customers who had more than one policy.
SQL: SELECT T1.customer_details ,  T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id  =  T2.Customer_id GROUP BY T1.customer_id HAVING count(*)  >  1

Question: What are the claim dates and settlement dates of all the settlements?
SQL: SELECT Date_Claim_Made ,  Date_Claim_Settled FROM Settlements

Question: Tell me the the claim date and settlement date for each settlement case.
SQL: SELECT Date_Claim_Made ,  Date_Claim_Settled FROM Settlements

Question: What is the most popular payment method?
SQL: SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) DESC LIMIT 1

Question: Which payment method is used the most often?
SQL: SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) DESC LIMIT 1

Question: With which kind of payment method were the least number of payments processed?
SQL: SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) ASC LIMIT 1

Question: What is the payment method that were used the least often?
SQL: SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) ASC LIMIT 1

Question: What is the total amount of payment?
SQL: SELECT sum(Amount_Payment) FROM Payments

Question: Compute the total amount of payment processed.
SQL: SELECT sum(Amount_Payment) FROM Payments

Question: What are all the distinct details of the customers?
SQL: SELECT DISTINCT customer_details FROM Customers

Question: Return the distinct customer details.
SQL: SELECT DISTINCT customer_details FROM Customers

Question: Which kind of policy type was chosen by the most customers?
SQL: SELECT Policy_Type_Code FROM Customer_Policies GROUP BY Policy_Type_Code ORDER BY count(*) DESC LIMIT 1

Question: Find the policy type the most customers choose.
SQL: SELECT Policy_Type_Code FROM Customer_Policies GROUP BY Policy_Type_Code ORDER BY count(*) DESC LIMIT 1

Question: How many settlements are there in total?
SQL: SELECT count(*) FROM Settlements

Question: Count the total number of settlements made.
SQL: SELECT count(*) FROM Settlements

Question: Which Payments were processed with Visa? List the payment Id, the date and the amount.
SQL: SELECT Payment_ID ,  Date_Payment_Made ,  Amount_Payment FROM Payments WHERE Payment_Method_Code  =  'Visa'

Question: Give me the payment Id, the date and the amount for all the payments processed with Visa.
SQL: SELECT Payment_ID ,  Date_Payment_Made ,  Amount_Payment FROM Payments WHERE Payment_Method_Code  =  'Visa'

Question: List the details of the customers who do not have any policies.
SQL: SELECT customer_details FROM Customers EXCEPT SELECT T1.customer_details FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.customer_id  =  T2.customer_id

Question: Which customers do not have any policies? Find the details of these customers.
SQL: SELECT customer_details FROM Customers EXCEPT SELECT T1.customer_details FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.customer_id  =  T2.customer_id

Question: List the date the claim was made, the date it was settled and the amount settled for all the claims which had exactly one settlement.
SQL: SELECT T1.claim_id ,  T1.date_claim_made ,  T1.Date_Claim_Settled FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id  =  T2.Claim_id GROUP BY T1.claim_id HAVING count(*)  =  1

Question: Which claims had exactly one settlement? For each, tell me the the date the claim was made, the date it was settled and the amount settled.
SQL: SELECT T1.claim_id ,  T1.date_claim_made ,  T1.Date_Claim_Settled FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id  =  T2.Claim_id GROUP BY T1.claim_id HAVING count(*)  =  1

Question: Find the total claimed amount of all the claims.
SQL: SELECT sum(Amount_Claimed) FROM Claims

Question: What is total amount claimed summed across all the claims?
SQL: SELECT sum(Amount_Claimed) FROM Claims