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

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 product types.
SQL: SELECT count(DISTINCT product_type_code) FROM products
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 address of customer 10.
SQL: SELECT T1.address_details FROM addresses AS T1 JOIN customer_addresses AS T2 ON T1.address_id  =  T2.address_id WHERE T2.customer_id  =  10
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 address for the customer with id 10?
SQL: SELECT T1.address_details FROM addresses AS T1 JOIN customer_addresses AS T2 ON T1.address_id  =  T2.address_id WHERE T2.customer_id  =  10
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 staff ids and genders of all staffs whose job title is Department Manager?
SQL: SELECT T1.staff_id ,  T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.job_title_code  =  "Department Manager"
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 staff ids and genders for any staff with the title Department Manager.
SQL: SELECT T1.staff_id ,  T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.job_title_code  =  "Department Manager"
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 payment method, return how many customers use it.
SQL: SELECT payment_method_code ,  count(*) FROM customers GROUP BY payment_method_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 customers use each payment method?
SQL: SELECT payment_method_code ,  count(*) FROM customers GROUP BY payment_method_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 id of the product that was ordered the most often?
SQL: SELECT product_id FROM order_items GROUP BY product_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 the product id for the product that was ordered most frequently.
SQL: SELECT product_id FROM order_items GROUP BY product_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 name, phone number and email address of the customer who made the largest number of orders?
SQL: SELECT T1.customer_name ,  T1.customer_phone ,  T1.customer_email FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T2.customer_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 name, phone number and email address for the customer with the most orders.
SQL: SELECT T1.customer_name ,  T1.customer_phone ,  T1.customer_email FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T2.customer_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 average price for each type of product?
SQL: SELECT product_type_code ,  avg(product_price) FROM products GROUP BY product_type_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 average price for each product type.
SQL: SELECT product_type_code ,  avg(product_price) FROM products GROUP BY product_type_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 department stores does the store chain South have?
SQL: SELECT count(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id  =  T2.dept_store_chain_id WHERE T2.dept_store_chain_name  =  "South"
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 stores the chain South has.
SQL: SELECT count(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id  =  T2.dept_store_chain_id WHERE T2.dept_store_chain_name  =  "South"
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 and job title of the staff who was assigned the latest?
SQL: SELECT T1.staff_name ,  T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id  =  T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 name and job title of the staff with the latest date assigned.
SQL: SELECT T1.staff_name ,  T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id  =  T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: addresses 
columns : [['address id', 'number'], ['address details', 'text']]

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

 -- Table: suppliers 
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]

 -- Table: department store chain 
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]

 -- Table: customers 
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]

 -- Table: products 
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]

 -- Table: supplier addresses 
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer addresses 
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]

 -- Table: customer orders 
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]

 -- Table: department stores 
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]

 -- Table: departments 
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]

 -- Table: order items 
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]

 -- Table: product suppliers 
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]

 -- Table: staff department assignments 
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]

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 product type, name and price for all the products supplied by supplier id 3.
SQL: SELECT T2.product_type_code ,  T2.product_name ,  T2.product_price FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id  =  T2.product_id WHERE T1.supplier_id  =  3