CREATE TABLE Customers (
    Customer_ID NUMBER PRIMARY KEY,
    Customer_Details TEXT
);
CREATE TABLE Staff (
    Staff_ID NUMBER PRIMARY KEY,
    Staff_Details TEXT
);
CREATE TABLE 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 Claim_Headers (
    Claim_Header_ID NUMBER PRIMARY KEY,
    Claim_Status_Code TEXT,
    Claim_Type_Code TEXT,
    Policy_ID NUMBER,
    Date_of_Claim TIME,
    Date_of_Settlement TIME,
    Amount_Claimed NUMBER,
    Amount_Piad NUMBER,
    FOREIGN KEY ("Policy_ID") REFERENCES Policies("Policy_ID")
);
CREATE TABLE Claims_Documents (
    Claim_ID NUMBER PRIMARY KEY,
    Document_Type_Code TEXT,
    Created_by_Staff_ID NUMBER,
    Created_Date NUMBER,
    FOREIGN KEY ("Created_by_Staff_ID") REFERENCES Staff("Staff_ID"),
    FOREIGN KEY ("Claim_ID") REFERENCES Claim_Headers("Claim_Header_ID")
);
CREATE TABLE Claims_Processing_Stages (
    Claim_Stage_ID NUMBER PRIMARY KEY,
    Next_Claim_Stage_ID NUMBER,
    Claim_Status_Name TEXT,
    Claim_Status_Description TEXT
);
CREATE TABLE Claims_Processing (
    Claim_Processing_ID NUMBER PRIMARY KEY,
    Claim_ID NUMBER,
    Claim_Outcome_Code TEXT,
    Claim_Stage_ID NUMBER,
    Staff_ID NUMBER,
    FOREIGN KEY ("Staff_ID") REFERENCES Staff("Staff_ID"),
    FOREIGN KEY ("Claim_ID") REFERENCES Claim_Headers("Claim_Header_ID")
);

Question: Find the names of all the customers and staff members.
SQL: SELECT customer_details FROM customers UNION SELECT staff_details FROM staff

Question: What are the names of the customers and staff members?
SQL: SELECT customer_details FROM customers UNION SELECT staff_details FROM staff

Question: Find the number of records of each policy type and its type code.
SQL: SELECT policy_type_code ,  count(*) FROM policies GROUP BY policy_type_code

Question: For each policy type, return its type code and its count in the record.
SQL: SELECT policy_type_code ,  count(*) FROM policies GROUP BY policy_type_code

Question: Find the name of the customer that has been involved in the most policies.
SQL: SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t2.customer_details ORDER BY count(*) DESC LIMIT 1

Question: Which customer have the most policies? Give me the customer details.
SQL: SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t2.customer_details ORDER BY count(*) DESC LIMIT 1

Question: What is the description of the claim status "Open"?
SQL: SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name  =  "Open"

Question: Find the description of the claim status "Open".
SQL: SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name  =  "Open"

Question: How many distinct claim outcome codes are there?
SQL: SELECT count(DISTINCT claim_outcome_code) FROM claims_processing

Question: Count the number of distinct claim outcome codes.
SQL: SELECT count(DISTINCT claim_outcome_code) FROM claims_processing

Question: Which customer is associated with the latest policy?
SQL: SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id WHERE t1.start_date  =  (SELECT max(start_date) FROM policies)

Question: Find the customer who started a policy most recently.
SQL: SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id WHERE t1.start_date  =  (SELECT max(start_date) FROM policies)