brief_instruction
stringlengths
16
224
instruction
stringlengths
687
8.77k
output
stringlengths
18
577
How many transactions correspond to each invoice number?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `How many transactions correspond to each invoice number?` to a syntactically-correct PostgreSQL query.
SELECT invoice_number , count(*) FROM Financial_transactions GROUP BY invoice_number
What is the invoice number and invoice date for the invoice with most number of transactions?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `What is the invoice number and invoice date for the invoice with most number of transactions?` to a syntactically-correct PostgreSQL query.
SELECT T2.invoice_number , T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number = T2.invoice_number GROUP BY T1.invoice_number ORDER BY count(*) DESC LIMIT 1
What is the invoice number and invoice date corresponding to the invoice with the greatest number of transactions?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `What is the invoice number and invoice date corresponding to the invoice with the greatest number of transactions?` to a syntactically-correct PostgreSQL query.
SELECT T2.invoice_number , T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number = T2.invoice_number GROUP BY T1.invoice_number ORDER BY count(*) DESC LIMIT 1
How many invoices do we have?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `How many invoices do we have?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM Invoices
Count the number of invoices.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Count the number of invoices.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM Invoices
Show invoice dates and order id and details for all invoices.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Show invoice dates and order id and details for all invoices.` to a syntactically-correct PostgreSQL query.
SELECT T1.invoice_date , T1.order_id , T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id
What are the invoice dates, order ids, and order details for all invoices?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `What are the invoice dates, order ids, and order details for all invoices?` to a syntactically-correct PostgreSQL query.
SELECT T1.invoice_date , T1.order_id , T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id
Show the order ids and the number of invoices for each order.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Show the order ids and the number of invoices for each order.` to a syntactically-correct PostgreSQL query.
SELECT order_id , count(*) FROM Invoices GROUP BY order_id
How many invoices correspond to each order id?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `How many invoices correspond to each order id?` to a syntactically-correct PostgreSQL query.
SELECT order_id , count(*) FROM Invoices GROUP BY order_id
What is the order id and order details for the order more than two invoices.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `What is the order id and order details for the order more than two invoices.` to a syntactically-correct PostgreSQL query.
SELECT T2.order_id , T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id GROUP BY T2.order_id HAVING count(*) > 2
Return the order ids and details for orderes with two or more invoices.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Return the order ids and details for orderes with two or more invoices.` to a syntactically-correct PostgreSQL query.
SELECT T2.order_id , T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id GROUP BY T2.order_id HAVING count(*) > 2
What is the customer last name, id and phone number with most number of orders?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `What is the customer last name, id and phone number with most number of orders?` to a syntactically-correct PostgreSQL query.
SELECT T2.customer_last_name , T1.customer_id , T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Return the last name, id and phone number of the customer who has made the greatest number of orders.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Return the last name, id and phone number of the customer who has made the greatest number of orders.` to a syntactically-correct PostgreSQL query.
SELECT T2.customer_last_name , T1.customer_id , T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Show all product names without an order.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Show all product names without an order.` to a syntactically-correct PostgreSQL query.
SELECT product_name FROM Products EXCEPT SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id = T2.product_id
What are the names of products that have never been ordered?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `What are the names of products that have never been ordered?` to a syntactically-correct PostgreSQL query.
SELECT product_name FROM Products EXCEPT SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id = T2.product_id
Show all product names and the total quantity ordered for each product name.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Show all product names and the total quantity ordered for each product name.` to a syntactically-correct PostgreSQL query.
SELECT T2.product_name , sum(T1.product_quantity) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name
What are the different product names, and what is the sum of quantity ordered for each product?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `What are the different product names, and what is the sum of quantity ordered for each product?` to a syntactically-correct PostgreSQL query.
SELECT T2.product_name , sum(T1.product_quantity) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name
Show the order ids and the number of items in each order.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Show the order ids and the number of items in each order.` to a syntactically-correct PostgreSQL query.
SELECT order_id , count(*) FROM Order_items GROUP BY order_id
How many order items correspond to each order id?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `How many order items correspond to each order id?` to a syntactically-correct PostgreSQL query.
SELECT order_id , count(*) FROM Order_items GROUP BY order_id
Show the product ids and the number of unique orders containing each product.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Show the product ids and the number of unique orders containing each product.` to a syntactically-correct PostgreSQL query.
SELECT product_id , count(DISTINCT order_id) FROM Order_items GROUP BY product_id
How many distinct order ids correspond to each product?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `How many distinct order ids correspond to each product?` to a syntactically-correct PostgreSQL query.
SELECT product_id , count(DISTINCT order_id) FROM Order_items GROUP BY product_id
Show all product names and the number of customers having an order on each product.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Show all product names and the number of customers having an order on each product.` to a syntactically-correct PostgreSQL query.
SELECT T2.product_name , count(*) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id JOIN Orders AS T3 ON T3.order_id = T1.order_id GROUP BY T2.product_name
What are teh names of the different products, as well as the number of customers who have ordered each product.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `What are teh names of the different products, as well as the number of customers who have ordered each product.` to a syntactically-correct PostgreSQL query.
SELECT T2.product_name , count(*) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id JOIN Orders AS T3 ON T3.order_id = T1.order_id GROUP BY T2.product_name
Show order ids and the number of products in each order.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Show order ids and the number of products in each order.` to a syntactically-correct PostgreSQL query.
SELECT order_id , count(DISTINCT product_id) FROM Order_items GROUP BY order_id
How many different products correspond to each order id?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `How many different products correspond to each order id?` to a syntactically-correct PostgreSQL query.
SELECT order_id , count(DISTINCT product_id) FROM Order_items GROUP BY order_id
Show order ids and the total quantity in each order.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Show order ids and the total quantity in each order.` to a syntactically-correct PostgreSQL query.
SELECT order_id , sum(product_quantity) FROM Order_items GROUP BY order_id
Give the order ids for all orders, as well as the total product quantity in each.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Give the order ids for all orders, as well as the total product quantity in each.` to a syntactically-correct PostgreSQL query.
SELECT order_id , sum(product_quantity) FROM Order_items GROUP BY order_id
How many products were not included in any order?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `How many products were not included in any order?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM products WHERE product_id NOT IN ( SELECT product_id FROM Order_items )
Count the number of products that were never ordered.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer first name', 'text'], ['customer middle initial', 'text'], ['customer last name', 'text'], ['gender', 'text'], ['email address', 'text'], ['login name', 'text'], ['login password', 'text'], ['phone number', 'text'], ['town city', 'text'], ['state county province', 'text'], ['country', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['date order placed', 'time'], ['order details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['order id', 'number'], ['invoice date', 'time']] -- Table: accounts columns : [['account id', 'number'], ['customer id', 'number'], ['date account opened', 'time'], ['account name', 'text'], ['other account details', 'text']] -- Table: product categories columns : [['production type code', 'text'], ['product type description', 'text'], ['vat rating', 'number']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['production type code', 'text'], ['unit price', 'number'], ['product name', 'text'], ['product color', 'text'], ['product size', 'text']] -- Table: financial transactions columns : [['transaction id', 'number'], ['account id', 'number'], ['invoice number', 'number'], ['transaction type', 'text'], ['transaction date', 'time'], ['transaction amount', 'number'], ['transaction comment', 'text'], ['other transaction details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number'], ['product quantity', 'text'], ['other order item details', 'text']] -- Table: invoice line items columns : [['order item id', 'number'], ['invoice number', 'number'], ['product id', 'number'], ['product title', 'text'], ['product quantity', 'text'], ['product price', 'number'], ['derived product cost', 'number'], ['derived vat payable', 'number'], ['derived total cost', '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. Translate `Count the number of products that were never ordered.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM products WHERE product_id NOT IN ( SELECT product_id FROM Order_items )
How many churches opened before 1850 are there?
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `How many churches opened before 1850 are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM Church WHERE Open_Date < 1850
Show the name, open date, and organizer for all churches.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the name, open date, and organizer for all churches.` to a syntactically-correct PostgreSQL query.
SELECT name , open_date , organized_by FROM Church
List all church names in descending order of opening date.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `List all church names in descending order of opening date.` to a syntactically-correct PostgreSQL query.
SELECT name FROM church ORDER BY open_date DESC
Show the opening year in whcih at least two churches opened.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the opening year in whcih at least two churches opened.` to a syntactically-correct PostgreSQL query.
SELECT open_date FROM church GROUP BY open_date HAVING count(*) >= 2
Show the organizer and name for churches that opened between 1830 and 1840.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the organizer and name for churches that opened between 1830 and 1840.` to a syntactically-correct PostgreSQL query.
SELECT organized_by , name FROM church WHERE open_date BETWEEN 1830 AND 1840
Show all opening years and the number of churches that opened in that year.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show all opening years and the number of churches that opened in that year.` to a syntactically-correct PostgreSQL query.
SELECT open_date , count(*) FROM church GROUP BY open_date
Show the name and opening year for three churches that opened most recently.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the name and opening year for three churches that opened most recently.` to a syntactically-correct PostgreSQL query.
SELECT name , open_date FROM church ORDER BY open_date DESC LIMIT 3
How many female people are older than 30 in our record?
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `How many female people are older than 30 in our record?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM people WHERE is_male = 'F' AND age > 30
Show the country where people older than 30 and younger than 25 are from.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the country where people older than 30 and younger than 25 are from.` to a syntactically-correct PostgreSQL query.
SELECT country FROM people WHERE age < 25 INTERSECT SELECT country FROM people WHERE age > 30
Show the minimum, maximum, and average age for all people.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the minimum, maximum, and average age for all people.` to a syntactically-correct PostgreSQL query.
SELECT min(age) , max(age) , avg(age) FROM people
Show the name and country for all people whose age is smaller than the average.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the name and country for all people whose age is smaller than the average.` to a syntactically-correct PostgreSQL query.
SELECT name , country FROM people WHERE age < (SELECT avg(age) FROM people)
Show the pair of male and female names in all weddings after year 2014
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the pair of male and female names in all weddings after year 2014` to a syntactically-correct PostgreSQL query.
SELECT T2.name , T3.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id WHERE T1.year > 2014
Show the name and age for all male people who don't have a wedding.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the name and age for all male people who don't have a wedding.` to a syntactically-correct PostgreSQL query.
SELECT name , age FROM people WHERE is_male = 'T' AND people_id NOT IN (SELECT male_id FROM wedding)
Show all church names except for those that had a wedding in year 2015.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show all church names except for those that had a wedding in year 2015.` to a syntactically-correct PostgreSQL query.
SELECT name FROM church EXCEPT SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id WHERE T2.year = 2015
Show all church names that have hosted least two weddings.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show all church names that have hosted least two weddings.` to a syntactically-correct PostgreSQL query.
SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id GROUP BY T1.church_id HAVING count(*) >= 2
Show the names for all females from Canada having a wedding in year 2016.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the names for all females from Canada having a wedding in year 2016.` to a syntactically-correct PostgreSQL query.
SELECT T2.name FROM wedding AS T1 JOIN people AS T2 ON T1.female_id = T2.people_id WHERE T1.year = 2016 AND T2.is_male = 'F' AND T2.country = 'Canada'
How many weddings are there in year 2016?
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `How many weddings are there in year 2016?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM wedding WHERE YEAR = 2016
Show the church names for the weddings of all people older than 30.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show the church names for the weddings of all people older than 30.` to a syntactically-correct PostgreSQL query.
SELECT T4.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id JOIN church AS T4 ON T4.church_id = T1.church_id WHERE T2.age > 30 OR T3.age > 30
Show all countries and the number of people from each country.
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `Show all countries and the number of people from each country.` to a syntactically-correct PostgreSQL query.
SELECT country , count(*) FROM people GROUP BY country
How many churches have a wedding in year 2016?
-- Language PostgreSQL -- Tables: -- Table: people columns : [['people id', 'number'], ['name', 'text'], ['country', 'text'], ['is male', 'text'], ['age', 'number']] -- Table: church columns : [['church id', 'number'], ['name', 'text'], ['organized by', 'text'], ['open date', 'number'], ['continuation of', 'text']] -- Table: wedding columns : [['church id', 'number'], ['male id', 'number'], ['female id', 'number'], ['year', '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. Translate `How many churches have a wedding in year 2016?` to a syntactically-correct PostgreSQL query.
SELECT COUNT (DISTINCT church_id) FROM wedding WHERE YEAR = 2016
How many artists do we have?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `How many artists do we have?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM artist
Count the number of artists.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Count the number of artists.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM artist
Show all artist name, age, and country ordered by the yeared they joined.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show all artist name, age, and country ordered by the yeared they joined.` to a syntactically-correct PostgreSQL query.
SELECT name , age , country FROM artist ORDER BY Year_Join
What are the names, ages, and countries of artists, sorted by the year they joined?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What are the names, ages, and countries of artists, sorted by the year they joined?` to a syntactically-correct PostgreSQL query.
SELECT name , age , country FROM artist ORDER BY Year_Join
What are all distinct country for artists?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What are all distinct country for artists?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT country FROM artist
Return the different countries for artists.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Return the different countries for artists.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT country FROM artist
Show all artist names and the year joined who are not from United States.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show all artist names and the year joined who are not from United States.` to a syntactically-correct PostgreSQL query.
SELECT name , year_join FROM artist WHERE country != 'United States'
What are the names and year of joining for artists that do not have the country "United States"?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What are the names and year of joining for artists that do not have the country "United States"?` to a syntactically-correct PostgreSQL query.
SELECT name , year_join FROM artist WHERE country != 'United States'
How many artists are above age 46 and joined after 1990?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `How many artists are above age 46 and joined after 1990?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM artist WHERE age > 46 AND year_join > 1990
Count the number of artists who are older than 46 and joined after 1990.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Count the number of artists who are older than 46 and joined after 1990.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM artist WHERE age > 46 AND year_join > 1990
What is the average and minimum age of all artists from United States.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What is the average and minimum age of all artists from United States.` to a syntactically-correct PostgreSQL query.
SELECT avg(age) , min(age) FROM artist WHERE country = 'United States'
Return the average and minimum ages across artists from the United States.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Return the average and minimum ages across artists from the United States.` to a syntactically-correct PostgreSQL query.
SELECT avg(age) , min(age) FROM artist WHERE country = 'United States'
What is the name of the artist who joined latest?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What is the name of the artist who joined latest?` to a syntactically-correct PostgreSQL query.
SELECT name FROM artist ORDER BY year_join DESC LIMIT 1
Return the name of the artist who has the latest join year.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Return the name of the artist who has the latest join year.` to a syntactically-correct PostgreSQL query.
SELECT name FROM artist ORDER BY year_join DESC LIMIT 1
How many exhibition are there in year 2005 or after?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `How many exhibition are there in year 2005 or after?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM exhibition WHERE YEAR >= 2005
Count the number of exhibitions that happened in or after 2005.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Count the number of exhibitions that happened in or after 2005.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM exhibition WHERE YEAR >= 2005
Show theme and year for all exhibitions with ticket prices lower than 15.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show theme and year for all exhibitions with ticket prices lower than 15.` to a syntactically-correct PostgreSQL query.
SELECT theme , YEAR FROM exhibition WHERE ticket_price < 15
What are the theme and year for all exhibitions that have a ticket price under 15?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What are the theme and year for all exhibitions that have a ticket price under 15?` to a syntactically-correct PostgreSQL query.
SELECT theme , YEAR FROM exhibition WHERE ticket_price < 15
Show all artist names and the number of exhibitions for each artist.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show all artist names and the number of exhibitions for each artist.` to a syntactically-correct PostgreSQL query.
SELECT T2.name , count(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id
How many exhibitions has each artist had?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `How many exhibitions has each artist had?` to a syntactically-correct PostgreSQL query.
SELECT T2.name , count(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id
What is the name and country for the artist with most number of exhibitions?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What is the name and country for the artist with most number of exhibitions?` to a syntactically-correct PostgreSQL query.
SELECT T2.name , T2.country FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id ORDER BY count(*) DESC LIMIT 1
Return the name and country corresponding to the artist who has had the most exhibitions.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Return the name and country corresponding to the artist who has had the most exhibitions.` to a syntactically-correct PostgreSQL query.
SELECT T2.name , T2.country FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id ORDER BY count(*) DESC LIMIT 1
Show names for artists without any exhibition.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show names for artists without any exhibition.` to a syntactically-correct PostgreSQL query.
SELECT name FROM artist WHERE artist_id NOT IN (SELECT artist_id FROM exhibition)
What are the names of artists that have not had any exhibitions?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What are the names of artists that have not had any exhibitions?` to a syntactically-correct PostgreSQL query.
SELECT name FROM artist WHERE artist_id NOT IN (SELECT artist_id FROM exhibition)
What is the theme and artist name for the exhibition with a ticket price higher than the average?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What is the theme and artist name for the exhibition with a ticket price higher than the average?` to a syntactically-correct PostgreSQL query.
SELECT T1.theme , T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.ticket_price > (SELECT avg(ticket_price) FROM exhibition)
Return the names of artists and the themes of their exhibitions that had a ticket price higher than average.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Return the names of artists and the themes of their exhibitions that had a ticket price higher than average.` to a syntactically-correct PostgreSQL query.
SELECT T1.theme , T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.ticket_price > (SELECT avg(ticket_price) FROM exhibition)
Show the average, minimum, and maximum ticket prices for exhibitions for all years before 2009.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show the average, minimum, and maximum ticket prices for exhibitions for all years before 2009.` to a syntactically-correct PostgreSQL query.
SELECT avg(ticket_price) , min(ticket_price) , max(ticket_price) FROM exhibition WHERE YEAR < 2009
What are the average, minimum, and maximum ticket prices for exhibitions that happened prior to 2009?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What are the average, minimum, and maximum ticket prices for exhibitions that happened prior to 2009?` to a syntactically-correct PostgreSQL query.
SELECT avg(ticket_price) , min(ticket_price) , max(ticket_price) FROM exhibition WHERE YEAR < 2009
Show theme and year for all exhibitions in an descending order of ticket price.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show theme and year for all exhibitions in an descending order of ticket price.` to a syntactically-correct PostgreSQL query.
SELECT theme , YEAR FROM exhibition ORDER BY ticket_price DESC
What are the themes and years for exhibitions, sorted by ticket price descending?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What are the themes and years for exhibitions, sorted by ticket price descending?` to a syntactically-correct PostgreSQL query.
SELECT theme , YEAR FROM exhibition ORDER BY ticket_price DESC
What is the theme, date, and attendance for the exhibition in year 2004?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What is the theme, date, and attendance for the exhibition in year 2004?` to a syntactically-correct PostgreSQL query.
SELECT T2.theme , T1.date , T1.attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T2.year = 2004
Return the themes, dates, and attendance for exhibitions that happened in 2004.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Return the themes, dates, and attendance for exhibitions that happened in 2004.` to a syntactically-correct PostgreSQL query.
SELECT T2.theme , T1.date , T1.attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T2.year = 2004
Show all artist names who didn't have an exhibition in 2004.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show all artist names who didn't have an exhibition in 2004.` to a syntactically-correct PostgreSQL query.
SELECT name FROM artist EXCEPT SELECT T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.year = 2004
What are the names of artists who did not have an exhibition in 2004?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What are the names of artists who did not have an exhibition in 2004?` to a syntactically-correct PostgreSQL query.
SELECT name FROM artist EXCEPT SELECT T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.year = 2004
Show the theme for exhibitions with both records of an attendance below 100 and above 500.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show the theme for exhibitions with both records of an attendance below 100 and above 500.` to a syntactically-correct PostgreSQL query.
SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance < 100 INTERSECT SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 500
Which themes have had corresponding exhibitions that have had attendance both below 100 and above 500?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Which themes have had corresponding exhibitions that have had attendance both below 100 and above 500?` to a syntactically-correct PostgreSQL query.
SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance < 100 INTERSECT SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 500
How many exhibitions have a attendance more than 100 or have a ticket price below 10?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `How many exhibitions have a attendance more than 100 or have a ticket price below 10?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 100 OR T2.ticket_price < 10
Count the number of exhibitions that have had an attendnance of over 100 or a ticket prices under 10.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Count the number of exhibitions that have had an attendnance of over 100 or a ticket prices under 10.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 100 OR T2.ticket_price < 10
Show all artist names with an average exhibition attendance over 200.
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `Show all artist names with an average exhibition attendance over 200.` to a syntactically-correct PostgreSQL query.
SELECT T3.name FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id JOIN artist AS T3 ON T3.artist_id = T2.artist_id GROUP BY T3.artist_id HAVING avg(T1.attendance) > 200
What are the names of artist whose exhibitions draw over 200 attendees on average?
-- Language PostgreSQL -- Tables: -- Table: artist columns : [['artist id', 'number'], ['name', 'text'], ['country', 'text'], ['year join', 'number'], ['age', 'number']] -- Table: exhibition columns : [['exhibition id', 'number'], ['year', 'number'], ['theme', 'text'], ['artist id', 'number'], ['ticket price', 'number']] -- Table: exhibition record columns : [['exhibition id', 'number'], ['date', 'text'], ['attendance', '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. Translate `What are the names of artist whose exhibitions draw over 200 attendees on average?` to a syntactically-correct PostgreSQL query.
SELECT T3.name FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id JOIN artist AS T3 ON T3.artist_id = T2.artist_id GROUP BY T3.artist_id HAVING avg(T1.attendance) > 200
Find the id of the item whose title is "orange".
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `Find the id of the item whose title is "orange".` to a syntactically-correct PostgreSQL query.
SELECT i_id FROM item WHERE title = "orange"
List all information in the item table.
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `List all information in the item table.` to a syntactically-correct PostgreSQL query.
SELECT * FROM item
Find the number of reviews.
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `Find the number of reviews.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM review
How many users are there?
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `How many users are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM useracct
Find the average and maximum rating of all reviews.
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `Find the average and maximum rating of all reviews.` to a syntactically-correct PostgreSQL query.
SELECT avg(rating) , max(rating) FROM review
Find the highest rank of all reviews.
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `Find the highest rank of all reviews.` to a syntactically-correct PostgreSQL query.
SELECT min(rank) FROM review
How many different users wrote some reviews?
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `How many different users wrote some reviews?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT u_id) FROM review
How many different items were reviewed by some users?
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `How many different items were reviewed by some users?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT i_id) FROM review
Find the number of items that did not receive any review.
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `Find the number of items that did not receive any review.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM item WHERE i_id NOT IN (SELECT i_id FROM review)
Find the names of users who did not leave any review.
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `Find the names of users who did not leave any review.` to a syntactically-correct PostgreSQL query.
SELECT name FROM useracct WHERE u_id NOT IN (SELECT u_id FROM review)
Find the names of goods that receive a rating of 10.
-- Language PostgreSQL -- Tables: -- Table: item columns : [['item id', 'number'], ['title', 'text']] -- Table: review columns : [['a id', 'number'], ['user id', 'number'], ['item id', 'number'], ['rating', 'number'], ['rank', 'number']] -- Table: useracct columns : [['user id', 'number'], ['name', 'text']] -- Table: trust columns : [['source user id', 'number'], ['target user id', 'number'], ['trust', '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. Translate `Find the names of goods that receive a rating of 10.` to a syntactically-correct PostgreSQL query.
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating = 10