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

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: For each product, return its id and the number of times it was ordered.
SQL: SELECT count(*) ,  T3.product_id FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: List the name and count of each product in all orders.
SQL: SELECT T3.product_name ,  count(*) FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: For each product, show its name and the number of times it was ordered.
SQL: SELECT T3.product_name ,  count(*) FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Find the ids of orders which are shipped after 2000-01-01.
SQL: SELECT order_id FROM shipments WHERE shipment_date > "2000-01-01"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Which orders have shipment after 2000-01-01? Give me the order ids.
SQL: SELECT order_id FROM shipments WHERE shipment_date > "2000-01-01"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Find the id of the order which is shipped most recently.
SQL: SELECT order_id FROM shipments WHERE shipment_date  =  (SELECT max(shipment_date) FROM shipments)
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Which order has the most recent shipment? Give me the order id.
SQL: SELECT order_id FROM shipments WHERE shipment_date  =  (SELECT max(shipment_date) FROM shipments)
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: List the names of all distinct products in alphabetical order.
SQL: SELECT DISTINCT product_name FROM products ORDER BY product_name
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Sort all the distinct products in alphabetical order.
SQL: SELECT DISTINCT product_name FROM products ORDER BY product_name
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: List the ids of all distinct orders ordered by placed date.
SQL: SELECT DISTINCT order_id FROM orders ORDER BY date_order_placed
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: What are ids of the all distinct orders, sorted by placement date?
SQL: SELECT DISTINCT order_id FROM orders ORDER BY date_order_placed
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: What is the id of the order which has the most items?
SQL: SELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Which order deals with the most items? Return the order id.
SQL: SELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: What is the name of the customer who has the largest number of orders?
SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Find the name of the customer who made the most orders.
SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Find the invoice numbers which are created before 1989-09-03 or after 2007-12-25.
SQL: SELECT invoice_number FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: What are the invoice numbers created before 1989-09-03 or after 2007-12-25?
SQL: SELECT invoice_number FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Find the distinct details of invoices which are created before 1989-09-03 or after 2007-12-25.
SQL: SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: What are the distinct details of invoices created before 1989-09-03 or after 2007-12-25?
SQL: SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: For each customer who has at least two orders, find the customer name and number of orders made.
SQL: SELECT T2.customer_name ,  count(*) FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  >=  2
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Which customers have made at least two orders? Give me each customer name and number of orders made.
SQL: SELECT T2.customer_name ,  count(*) FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  >=  2
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Find the name of the customers who have at most two orders.
SQL: SELECT T2.customer_name FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  <=  2
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: What are the names of the customers who have made two or less orders?
SQL: SELECT T2.customer_name FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  <=  2
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: List the names of the customers who have once bought product "food".
SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T4.product_name = "food" GROUP BY T1.customer_id HAVING count(*)  >=  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: What are the names of the customers who bought product "food" at least once?
SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T4.product_name = "food" GROUP BY T1.customer_id HAVING count(*)  >=  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: List the names of customers who have once canceled the purchase of the product "food" (the item status is "Cancel").
SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T3.order_item_status = "Cancel" AND T4.product_name = "food" GROUP BY T1.customer_id HAVING count(*)  >=  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']]

 -- Table: invoices 
columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']]

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

 -- Table: products 
columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']]

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

 -- Table: shipments 
columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']]

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

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



Question: Which customers have ever canceled the purchase of the product "food" (the item status is "Cancel")?
SQL: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T3.order_item_status = "Cancel" AND T4.product_name = "food" GROUP BY T1.customer_id HAVING count(*)  >=  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: architect 
columns : [['id', 'text'], ['name', 'text'], ['nationality', 'text'], ['gender', 'text']]

 -- Table: bridge 
columns : [['architect id', 'number'], ['id', 'number'], ['name', 'text'], ['location', 'text'], ['length meters', 'number'], ['length feet', 'number']]

 -- Table: mill 
columns : [['architect id', 'number'], ['id', 'number'], ['location', 'text'], ['name', 'text'], ['type', 'text'], ['built year', 'number'], ['notes', 'text']]

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 architects are female?
SQL: SELECT count(*) FROM architect WHERE gender  =  'female'
-- Language PostgreSQL
        -- Tables: 
             -- Table: architect 
columns : [['id', 'text'], ['name', 'text'], ['nationality', 'text'], ['gender', 'text']]

 -- Table: bridge 
columns : [['architect id', 'number'], ['id', 'number'], ['name', 'text'], ['location', 'text'], ['length meters', 'number'], ['length feet', 'number']]

 -- Table: mill 
columns : [['architect id', 'number'], ['id', 'number'], ['location', 'text'], ['name', 'text'], ['type', 'text'], ['built year', 'number'], ['notes', 'text']]

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 name, nationality and id of all male architects ordered by their names lexicographically.
SQL: SELECT name ,  nationality ,  id FROM architect WHERE gender  =  'male' ORDER BY name
-- Language PostgreSQL
        -- Tables: 
             -- Table: architect 
columns : [['id', 'text'], ['name', 'text'], ['nationality', 'text'], ['gender', 'text']]

 -- Table: bridge 
columns : [['architect id', 'number'], ['id', 'number'], ['name', 'text'], ['location', 'text'], ['length meters', 'number'], ['length feet', 'number']]

 -- Table: mill 
columns : [['architect id', 'number'], ['id', 'number'], ['location', 'text'], ['name', 'text'], ['type', 'text'], ['built year', 'number'], ['notes', 'text']]

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 maximum length in meters for the bridges and what are the architects' names?
SQL: SELECT max(T1.length_meters) ,  T2.name FROM bridge AS T1 JOIN architect AS T2 ON T1.architect_id  =  T2.id
-- Language PostgreSQL
        -- Tables: 
             -- Table: architect 
columns : [['id', 'text'], ['name', 'text'], ['nationality', 'text'], ['gender', 'text']]

 -- Table: bridge 
columns : [['architect id', 'number'], ['id', 'number'], ['name', 'text'], ['location', 'text'], ['length meters', 'number'], ['length feet', 'number']]

 -- Table: mill 
columns : [['architect id', 'number'], ['id', 'number'], ['location', 'text'], ['name', 'text'], ['type', 'text'], ['built year', 'number'], ['notes', 'text']]

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 length in feet of the bridges?
SQL: SELECT avg(length_feet) FROM bridge
-- Language PostgreSQL
        -- Tables: 
             -- Table: architect 
columns : [['id', 'text'], ['name', 'text'], ['nationality', 'text'], ['gender', 'text']]

 -- Table: bridge 
columns : [['architect id', 'number'], ['id', 'number'], ['name', 'text'], ['location', 'text'], ['length meters', 'number'], ['length feet', 'number']]

 -- Table: mill 
columns : [['architect id', 'number'], ['id', 'number'], ['location', 'text'], ['name', 'text'], ['type', 'text'], ['built year', 'number'], ['notes', 'text']]

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



Question: What are the names and year of construction for the mills of 'Grondzeiler' type?
SQL: SELECT name ,  built_year FROM mill WHERE TYPE  =  'Grondzeiler'