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

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: Of all the claims, what was the earliest date when any claim was made?
SQL: SELECT Date_Claim_Made FROM Claims ORDER BY Date_Claim_Made ASC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: Tell me the the date when the first claim was made.
SQL: SELECT Date_Claim_Made FROM Claims ORDER BY Date_Claim_Made ASC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 total amount of settlement made for all the settlements?
SQL: SELECT sum(Amount_Settled) FROM Settlements
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: Compute the total amount of settlement across all the settlements.
SQL: SELECT sum(Amount_Settled) FROM Settlements
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 claim dates and settlement dates of all the settlements?
SQL: SELECT Date_Claim_Made ,  Date_Claim_Settled FROM Settlements
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: Tell me the the claim date and settlement date for each settlement case.
SQL: SELECT Date_Claim_Made ,  Date_Claim_Settled FROM Settlements
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 most popular payment method?
SQL: SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 total amount of payment?
SQL: SELECT sum(Amount_Payment) FROM Payments
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: Compute the total amount of payment processed.
SQL: SELECT sum(Amount_Payment) FROM Payments
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 all the distinct details of the customers?
SQL: SELECT DISTINCT customer_details FROM Customers
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: Return the distinct customer details.
SQL: SELECT DISTINCT customer_details FROM Customers
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 settlements are there in total?
SQL: SELECT count(*) FROM Settlements
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 total number of settlements made.
SQL: SELECT count(*) FROM Settlements
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 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'
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: 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'
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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: 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 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
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 total claimed amount of all the claims.
SQL: SELECT sum(Amount_Claimed) FROM Claims
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

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

 -- Table: claims 
columns : [['claim id', 'number'], ['policy id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number']]

 -- Table: settlements 
columns : [['settlement id', 'number'], ['claim id', 'number'], ['date claim made', 'time'], ['date claim settled', 'time'], ['amount claimed', 'number'], ['amount settled', 'number'], ['customer policy id', 'number']]

 -- Table: payments 
columns : [['payment id', 'number'], ['settlement id', 'number'], ['payment method code', 'text'], ['date payment made', 'time'], ['amount payment', '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 total amount claimed summed across all the claims?
SQL: SELECT sum(Amount_Claimed) FROM Claims
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 department has the largest number of employees?
SQL: SELECT name FROM department GROUP BY departmentID ORDER BY count(departmentID) DESC LIMIT 1;
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 department with the most employees.
SQL: SELECT name FROM department GROUP BY departmentID ORDER BY count(departmentID) DESC LIMIT 1;
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 employee id of the head whose department has the least number of employees?
SQL: SELECT head FROM department GROUP BY departmentID ORDER BY count(departmentID) LIMIT 1;