sert121/SpiderSQL huggingface dataset:
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: What is the name of the customer who has made the largest amount of claim in a single claim?
SQL: SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id  =  t2.policy_id JOIN customers AS t3 ON t2.customer_id  =  t3.customer_id WHERE t1.amount_claimed  =  (SELECT max(amount_claimed) FROM claim_headers)
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Which customer made the largest amount of claim in a single claim? Return the customer details.
SQL: SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id  =  t2.policy_id JOIN customers AS t3 ON t2.customer_id  =  t3.customer_id WHERE t1.amount_claimed  =  (SELECT max(amount_claimed) FROM claim_headers)
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: What is the name of the customer who has made the minimum amount of payment in one claim?
SQL: SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id  =  t2.policy_id JOIN customers AS t3 ON t2.customer_id  =  t3.customer_id WHERE t1.amount_piad  =  (SELECT min(amount_piad) FROM claim_headers)
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Which customer made the smallest amount of claim in one claim? Return the customer details.
SQL: SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id  =  t2.policy_id JOIN customers AS t3 ON t2.customer_id  =  t3.customer_id WHERE t1.amount_piad  =  (SELECT min(amount_piad) FROM claim_headers)
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Find the names of customers who have no policies associated.
SQL: SELECT customer_details FROM customers EXCEPT SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: What are the names of customers who do not have any policies?
SQL: SELECT customer_details FROM customers EXCEPT SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: How many claim processing stages are there in total?
SQL: SELECT count(*) FROM claims_processing_stages
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Find the number of distinct stages in claim processing.
SQL: SELECT count(*) FROM claims_processing_stages
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: What is the name of the claim processing stage that most of the claims are on?
SQL: SELECT t2.claim_status_name FROM claims_processing AS t1 JOIN claims_processing_stages AS t2 ON t1.claim_stage_id  =  t2.claim_stage_id GROUP BY t1.claim_stage_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Which claim processing stage has the most claims? Show the claim status name.
SQL: SELECT t2.claim_status_name FROM claims_processing AS t1 JOIN claims_processing_stages AS t2 ON t1.claim_stage_id  =  t2.claim_stage_id GROUP BY t1.claim_stage_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Find the names of customers whose name contains "Diana".
SQL: SELECT customer_details FROM customers WHERE customer_details LIKE "%Diana%"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Which customers have the substring "Diana" in their names? Return the customer details.
SQL: SELECT customer_details FROM customers WHERE customer_details LIKE "%Diana%"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Find the names of the customers who have an deputy policy.
SQL: SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id WHERE t1.policy_type_code  =  "Deputy"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Which customers have an insurance policy with the type code "Deputy"? Give me the customer details.
SQL: SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id WHERE t1.policy_type_code  =  "Deputy"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Find the names of customers who either have an deputy policy or uniformed policy.
SQL: SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id WHERE t1.policy_type_code  =  "Deputy" OR t1.policy_type_code  =  "Uniform"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Which customers have an insurance policy with the type code "Deputy" or "Uniform"? Return the customer details.
SQL: SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id  =  t2.customer_id WHERE t1.policy_type_code  =  "Deputy" OR t1.policy_type_code  =  "Uniform"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Find the names of all the customers and staff members.
SQL: SELECT customer_details FROM customers UNION SELECT staff_details FROM staff
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: What are the names of the customers and staff members?
SQL: SELECT customer_details FROM customers UNION SELECT staff_details FROM staff
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: What is the description of the claim status "Open"?
SQL: SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name  =  "Open"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Find the description of the claim status "Open".
SQL: SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name  =  "Open"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: How many distinct claim outcome codes are there?
SQL: SELECT count(DISTINCT claim_outcome_code) FROM claims_processing
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



Question: Count the number of distinct claim outcome codes.
SQL: SELECT count(DISTINCT claim_outcome_code) FROM claims_processing
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



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)
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: staff 
columns : [['staff id', 'number'], ['staff details', 'text']]

 -- Table: policies 
columns : [['policy id', 'number'], ['customer id', 'number'], ['policy type code', 'text'], ['start date', 'time'], ['end date', 'time']]

 -- Table: claim headers 
columns : [['claim header id', 'number'], ['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']]

 -- Table: claims documents 
columns : [['claim id', 'number'], ['document type code', 'text'], ['created by staff id', 'number'], ['created date', 'number']]

 -- Table: claims processing stages 
columns : [['claim stage id', 'number'], ['next claim stage id', 'number'], ['claim status name', 'text'], ['claim status description', 'text']]

 -- Table: claims processing 
columns : [['claim processing id', 'number'], ['claim id', 'number'], ['claim outcome code', 'text'], ['claim stage id', 'number'], ['staff id', 'number']]

You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. 
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.



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)