brief_instruction
stringlengths
16
224
instruction
stringlengths
687
8.77k
output
stringlengths
18
577
How many budgets are above 3000 in year 2001 or before?
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 budgets are above 3000 in year 2001 or before?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001
Count the number of budgets in year 2001 or before whose budgeted amount is greater than 3000
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 budgets in year 2001 or before whose budgeted amount is greater than 3000` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001
Show each school name, its budgeted amount, and invested amount in year 2002 or after.
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 each school name, its budgeted amount, and invested amount in year 2002 or after.` to a syntactically-correct PostgreSQL query.
SELECT T2.school_name , T1.budgeted , T1.invested FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.year >= 2002
Show all donor names.
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 donor names.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT donator_name FROM endowment
How many budget record has a budget amount smaller than the invested amount?
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 budget record has a budget amount smaller than the invested amount?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM budget WHERE budgeted < invested
What is the total budget amount for school "Glenn" in all years?
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 total budget amount for school "Glenn" in all years?` to a syntactically-correct PostgreSQL query.
SELECT sum(T1.budgeted) FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn'
Show the names of schools with a total budget amount greater than 100 or a total endowment greater than 10.
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 of schools with a total budget amount greater than 100 or a total endowment greater than 10.` to a syntactically-correct PostgreSQL query.
SELECT T2.school_name FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN endowment AS T3 ON T2.school_id = T3.school_id GROUP BY T2.school_name HAVING sum(T1.budgeted) > 100 OR sum(T3.amount) > 10
Find the names of schools that have more than one donator with donation amount above 8.5.
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 schools that have more than one donator with donation amount above 8.5.` to a syntactically-correct PostgreSQL query.
SELECT T2.School_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.amount > 8.5 GROUP BY T1.school_id HAVING count(*) > 1
Find the number of schools that have more than one donator whose donation amount is less than 8.5.
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 schools that have more than one donator whose donation amount is less than 8.5.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM (SELECT * FROM endowment WHERE amount > 8.5 GROUP BY school_id HAVING count(*) > 1)
List the name, IHSAA Football Class, and Mascot of the schools that have more than 6000 of budgeted amount or were founded before 2003, in the order of percent of total invested budget and total budgeted budget.
-- Language PostgreSQL -- Tables: -- Table: school columns : [['school id', 'text'], ['school name', 'text'], ['location', 'text'], ['mascot', 'text'], ['enrollment', 'number'], ['ihsaa class', 'text'], ['ihsaa football class', 'text'], ['county', 'text']] -- Table: budget columns : [['school id', 'number'], ['year', 'number'], ['budgeted', 'number'], ['total budget percent budgeted', 'number'], ['invested', 'number'], ['total budget percent invested', 'number'], ['budget invested percent', 'text']] -- Table: endowment columns : [['endowment id', 'number'], ['school id', 'number'], ['donator name', 'text'], ['amount', '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 the name, IHSAA Football Class, and Mascot of the schools that have more than 6000 of budgeted amount or were founded before 2003, in the order of percent of total invested budget and total budgeted budget.` to a syntactically-correct PostgreSQL query.
SELECT T1.School_name , T1.Mascot , T1.IHSAA_Football_Class FROM school AS T1 JOIN budget AS T2 ON T1.school_id = T2.school_id WHERE Budgeted > 6000 OR YEAR < 2003 ORDER BY T2.total_budget_percent_invested , T2.total_budget_percent_budgeted
How many buildings are there?
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many buildings are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM building
Show the name, street address, and number of floors for all buildings ordered by the number of floors.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show the name, street address, and number of floors for all buildings ordered by the number of floors.` to a syntactically-correct PostgreSQL query.
SELECT name , street_address , floors FROM building ORDER BY floors
What is the name of the tallest building?
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the name of the tallest building?` to a syntactically-correct PostgreSQL query.
SELECT name FROM building ORDER BY height_feet DESC LIMIT 1
What are the average, maximum, and minimum number of floors for all buildings?
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the average, maximum, and minimum number of floors for all buildings?` to a syntactically-correct PostgreSQL query.
SELECT avg(floors) , max(floors) , min(floors) FROM building
Show the number of buildings with a height above the average or a number of floors above the average.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show the number of buildings with a height above the average or a number of floors above the average.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM building WHERE height_feet > (SELECT avg(height_feet) FROM building) OR floors > (SELECT avg(floors) FROM building)
List the names of buildings with at least 200 feet of height and with at least 20 floors.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the names of buildings with at least 200 feet of height and with at least 20 floors.` to a syntactically-correct PostgreSQL query.
SELECT name FROM building WHERE height_feet >= 200 AND floors >= 20
Show the names and locations of institutions that are founded after 1990 and have the type "Private".
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show the names and locations of institutions that are founded after 1990 and have the type "Private".` to a syntactically-correct PostgreSQL query.
SELECT institution , LOCATION FROM institution WHERE founded > 1990 AND TYPE = 'Private'
Show institution types, along with the number of institutions and total enrollment for each type.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show institution types, along with the number of institutions and total enrollment for each type.` to a syntactically-correct PostgreSQL query.
SELECT TYPE , count(*) , sum(enrollment) FROM institution GROUP BY TYPE
Show the institution type with the largest number of institutions.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show the institution type with the largest number of institutions.` to a syntactically-correct PostgreSQL query.
SELECT TYPE FROM institution GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1
Show the institution type with an institution founded after 1990 and an institution with at least 1000 enrollment.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show the institution type with an institution founded after 1990 and an institution with at least 1000 enrollment.` to a syntactically-correct PostgreSQL query.
SELECT TYPE FROM institution WHERE founded > 1990 AND enrollment >= 1000
Show the name of buildings that do not have any institution.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show the name of buildings that do not have any institution.` to a syntactically-correct PostgreSQL query.
SELECT name FROM building WHERE building_id NOT IN (SELECT building_id FROM institution)
Show the names of buildings except for those having an institution founded in 2003.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show the names of buildings except for those having an institution founded in 2003.` to a syntactically-correct PostgreSQL query.
SELECT name FROM building EXCEPT SELECT T1.name FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded = 2003
For each building, show the name of the building and the number of institutions in it.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `For each building, show the name of the building and the number of institutions in it.` to a syntactically-correct PostgreSQL query.
SELECT T1.name , count(*) FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id GROUP BY T1.building_id
Show the names and heights of buildings with at least two institutions founded after 1880.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show the names and heights of buildings with at least two institutions founded after 1880.` to a syntactically-correct PostgreSQL query.
SELECT T1.name , T1.height_feet FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded > 1880 GROUP BY T1.building_id HAVING count(*) >= 2
Show all the distinct institution types.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show all the distinct institution types.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT TYPE FROM institution
Show institution names along with the number of proteins for each institution.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show institution names along with the number of proteins for each institution.` to a syntactically-correct PostgreSQL query.
SELECT T1.institution , count(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id GROUP BY T1.institution_id
How many proteins are associated with an institution founded after 1880 or an institution with type "Private"?
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many proteins are associated with an institution founded after 1880 or an institution with type "Private"?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id WHERE T1.founded > 1880 OR T1.type = 'Private'
Show the protein name and the institution name.
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Show the protein name and the institution name.` to a syntactically-correct PostgreSQL query.
SELECT T2.protein_name , T1.institution FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id
How many proteins are associated with an institution in a building with at least 20 floors?
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many proteins are associated with an institution in a building with at least 20 floors?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id JOIN building AS T3 ON T3.building_id = T1.building_id WHERE T3.floors >= 20
How many institutions do not have an associated protein in our record?
-- Language PostgreSQL -- Tables: -- Table: building columns : [['building id', 'text'], ['name', 'text'], ['street address', 'text'], ['years as tallest', 'text'], ['height feet', 'number'], ['floors', 'number']] -- Table: institution columns : [['institution id', 'text'], ['institution', 'text'], ['location', 'text'], ['founded', 'number'], ['type', 'text'], ['enrollment', 'number'], ['team', 'text'], ['primary conference', 'text'], ['building id', 'text']] -- Table: protein columns : [['common name', 'text'], ['protein name', 'text'], ['divergence from human lineage', 'number'], ['accession number', 'text'], ['sequence length', 'number'], ['sequence identity to human protein', 'text'], ['institution id', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many institutions do not have an associated protein in our record?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM institution WHERE institution_id NOT IN (SELECT institution_id FROM protein)
Show all the locations where no cinema has capacity over 800.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 the locations where no cinema has capacity over 800.` to a syntactically-correct PostgreSQL query.
SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800
Show all the locations where some cinemas were opened in both year 2010 and year 2011.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 the locations where some cinemas were opened in both year 2010 and year 2011.` to a syntactically-correct PostgreSQL query.
SELECT LOCATION FROM cinema WHERE openning_year = 2010 INTERSECT SELECT LOCATION FROM cinema WHERE openning_year = 2011
How many cinema do we have?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 cinema do we have?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM cinema
Count the number of cinemas.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 cinemas.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM cinema
Show name, opening year, and capacity for each cinema.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 name, opening year, and capacity for each cinema.` to a syntactically-correct PostgreSQL query.
SELECT name , openning_year , capacity FROM cinema
Show the cinema name and location for cinemas with capacity above average.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 cinema name and location for cinemas with capacity above average.` to a syntactically-correct PostgreSQL query.
SELECT name , LOCATION FROM cinema WHERE capacity > (SELECT avg(capacity) FROM cinema)
What are all the locations with a cinema?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 the locations with a cinema?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT LOCATION FROM cinema
Find the distinct locations that has a cinema.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 distinct locations that has a cinema.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT LOCATION FROM cinema
Show all the cinema names and opening years in descending order of opening year.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 the cinema names and opening years in descending order of opening year.` to a syntactically-correct PostgreSQL query.
SELECT name , openning_year FROM cinema ORDER BY openning_year DESC
What are the name and location of the cinema with the largest capacity?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 name and location of the cinema with the largest capacity?` to a syntactically-correct PostgreSQL query.
SELECT name , LOCATION FROM cinema ORDER BY capacity DESC LIMIT 1
Show the average, minimum, and maximum capacity for all the cinemas opened in year 2011 or later.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 capacity for all the cinemas opened in year 2011 or later.` to a syntactically-correct PostgreSQL query.
SELECT avg(capacity) , min(capacity) , max(capacity) FROM cinema WHERE openning_year >= 2011
Show each location and the number of cinemas there.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 each location and the number of cinemas there.` to a syntactically-correct PostgreSQL query.
SELECT LOCATION , count(*) FROM cinema GROUP BY LOCATION
What is the location with the most cinemas opened in year 2010 or later?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 location with the most cinemas opened in year 2010 or later?` to a syntactically-correct PostgreSQL query.
SELECT LOCATION FROM cinema WHERE openning_year >= 2010 GROUP BY LOCATION ORDER BY count(*) DESC LIMIT 1
Show all the locations with at least two cinemas with capacity above 300.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 the locations with at least two cinemas with capacity above 300.` to a syntactically-correct PostgreSQL query.
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) >= 2
Which locations have 2 or more cinemas with capacity over 300?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 locations have 2 or more cinemas with capacity over 300?` to a syntactically-correct PostgreSQL query.
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) >= 2
Show the title and director for all films.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 title and director for all films.` to a syntactically-correct PostgreSQL query.
SELECT title , directed_by FROM film
What are the title and director of each film?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 title and director of each film?` to a syntactically-correct PostgreSQL query.
SELECT title , directed_by FROM film
Show all directors.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 directors.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT directed_by FROM film
Who are all the directors?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 `Who are all the directors?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT directed_by FROM film
List all directors along with the number of films directed by each director.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 directors along with the number of films directed by each director.` to a syntactically-correct PostgreSQL query.
SELECT directed_by , count(*) FROM film GROUP BY directed_by
What is total number of show times per dat for each cinema?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 total number of show times per dat for each cinema?` to a syntactically-correct PostgreSQL query.
SELECT T2.name , sum(T1.show_times_per_day) FROM schedule AS T1 JOIN cinema AS T2 ON T1.cinema_id = T2.cinema_id GROUP BY T1.cinema_id
What are the title and maximum price of each film?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 title and maximum price of each film?` to a syntactically-correct PostgreSQL query.
SELECT T2.title , max(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id
Give me the title and highest price for each film.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 me the title and highest price for each film.` to a syntactically-correct PostgreSQL query.
SELECT T2.title , max(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id
Show cinema name, film title, date, and price for each record in schedule.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 cinema name, film title, date, and price for each record in schedule.` to a syntactically-correct PostgreSQL query.
SELECT T3.name , T2.title , T1.date , T1.price FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id JOIN cinema AS T3 ON T1.cinema_id = T3.cinema_id
What are the title and director of the films without any schedule?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 title and director of the films without any schedule?` to a syntactically-correct PostgreSQL query.
SELECT title , directed_by FROM film WHERE film_id NOT IN (SELECT film_id FROM schedule)
Show director with the largest number of show times in total.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 director with the largest number of show times in total.` to a syntactically-correct PostgreSQL query.
SELECT T2.directed_by FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.directed_by ORDER BY sum(T1.show_times_per_day) DESC LIMIT 1
Find the locations that have more than one movie theater with capacity above 300.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 locations that have more than one movie theater with capacity above 300.` to a syntactically-correct PostgreSQL query.
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) > 1
In which locations are there more than one movie theater with capacity above 300?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 `In which locations are there more than one movie theater with capacity above 300?` to a syntactically-correct PostgreSQL query.
SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) > 1
How many films have the word 'Dummy' in their titles?
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 films have the word 'Dummy' in their titles?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM film WHERE title LIKE "%Dummy%"
Count the number of films whose title contains the word 'Dummy'.
-- Language PostgreSQL -- Tables: -- Table: film columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']] -- Table: cinema columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']] -- Table: schedule columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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 films whose title contains the word 'Dummy'.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM film WHERE title LIKE "%Dummy%"
Are the customers holding coupons with amount 500 bad or good?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Are the customers holding coupons with amount 500 bad or good?` to a syntactically-correct PostgreSQL query.
SELECT T1.good_or_bad_customer FROM customers AS T1 JOIN discount_coupons AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.coupon_amount = 500
How many bookings did each customer make? List the customer id, first name, and the count.
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many bookings did each customer make? List the customer id, first name, and the count.` to a syntactically-correct PostgreSQL query.
SELECT T1.customer_id , T1.first_name , count(*) FROM Customers AS T1 JOIN bookings AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id
What is the maximum total amount paid by a customer? List the customer id and amount.
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the maximum total amount paid by a customer? List the customer id and amount.` to a syntactically-correct PostgreSQL query.
SELECT customer_id , sum(amount_paid) FROM Payments GROUP BY customer_id ORDER BY sum(amount_paid) DESC LIMIT 1
What are the id and the amount of refund of the booking that incurred the most times of payments?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the id and the amount of refund of the booking that incurred the most times of payments?` to a syntactically-correct PostgreSQL query.
SELECT T1.booking_id , T1.amount_of_refund FROM Bookings AS T1 JOIN Payments AS T2 ON T1.booking_id = T2.booking_id GROUP BY T1.booking_id ORDER BY count(*) DESC LIMIT 1
What is the id of the product that is booked for 3 times?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the id of the product that is booked for 3 times?` to a syntactically-correct PostgreSQL query.
SELECT product_id FROM products_booked GROUP BY product_id HAVING count(*) = 3
What is the product description of the product booked with an amount of 102.76?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the product description of the product booked with an amount of 102.76?` to a syntactically-correct PostgreSQL query.
SELECT T2.product_description FROM products_booked AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.booked_amount = 102.76
What are the start date and end date of the booking that has booked the product named 'Book collection A'?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the start date and end date of the booking that has booked the product named 'Book collection A'?` to a syntactically-correct PostgreSQL query.
SELECT T3.booking_start_date , T3.booking_end_date FROM Products_for_hire AS T1 JOIN products_booked AS T2 ON T1.product_id = T2.product_id JOIN bookings AS T3 ON T2.booking_id = T3.booking_id WHERE T1.product_name = 'Book collection A'
What are the names of products whose availability equals to 1?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the names of products whose availability equals to 1?` to a syntactically-correct PostgreSQL query.
SELECT T2.product_name FROM view_product_availability AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.available_yn = 1
How many different product types are there?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many different product types are there?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT product_type_code) FROM products_for_hire
What are the first name, last name, and gender of all the good customers? Order by their last name.
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the first name, last name, and gender of all the good customers? Order by their last name.` to a syntactically-correct PostgreSQL query.
SELECT first_name , last_name , gender_mf FROM customers WHERE good_or_bad_customer = 'good' ORDER BY last_name
What is the average amount due for all the payments?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the average amount due for all the payments?` to a syntactically-correct PostgreSQL query.
SELECT avg(amount_due) FROM payments
What are the maximum, minimum, and average booked count for the products booked?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the maximum, minimum, and average booked count for the products booked?` to a syntactically-correct PostgreSQL query.
SELECT max(booked_count) , min(booked_count) , avg(booked_count) FROM products_booked
What are all the distinct payment types?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are all the distinct payment types?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT payment_type_code FROM payments
What are the daily hire costs for the products with substring 'Book' in its name?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the daily hire costs for the products with substring 'Book' in its name?` to a syntactically-correct PostgreSQL query.
SELECT daily_hire_cost FROM Products_for_hire WHERE product_name LIKE '%Book%'
How many products are never booked with amount higher than 200?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many products are never booked with amount higher than 200?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM Products_for_hire WHERE product_id NOT IN ( SELECT product_id FROM products_booked WHERE booked_amount > 200 )
What are the coupon amount of the coupons owned by both good and bad customers?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the coupon amount of the coupons owned by both good and bad customers?` to a syntactically-correct PostgreSQL query.
SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'good' INTERSECT SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'bad'
What are the payment date of the payment with amount paid higher than 300 or with payment type is 'Check'
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the payment date of the payment with amount paid higher than 300 or with payment type is 'Check'` to a syntactically-correct PostgreSQL query.
SELECT payment_date FROM payments WHERE amount_paid > 300 OR payment_type_code = 'Check'
What are the names and descriptions of the products that are of 'Cutlery' type and have daily hire cost lower than 20?
-- Language PostgreSQL -- Tables: -- Table: discount coupons columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']] -- Table: customers columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']] -- Table: bookings columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']] -- Table: products for hire columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']] -- Table: payments columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']] -- Table: products booked columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']] -- Table: view product availability columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the names and descriptions of the products that are of 'Cutlery' type and have daily hire cost lower than 20?` to a syntactically-correct PostgreSQL query.
SELECT product_name , product_description FROM products_for_hire WHERE product_type_code = 'Cutlery' AND daily_hire_cost < 20
How many phones are there?
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 phones are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM phone
List the names of phones in ascending order of price.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 the names of phones in ascending order of price.` to a syntactically-correct PostgreSQL query.
SELECT Name FROM phone ORDER BY Price ASC
What are the memories and carriers of phones?
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 memories and carriers of phones?` to a syntactically-correct PostgreSQL query.
SELECT Memory_in_G , Carrier FROM phone
List the distinct carriers of phones with memories bigger than 32.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 the distinct carriers of phones with memories bigger than 32.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT Carrier FROM phone WHERE Memory_in_G > 32
Show the names of phones with carrier either "Sprint" or "TMobile".
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 of phones with carrier either "Sprint" or "TMobile".` to a syntactically-correct PostgreSQL query.
SELECT Name FROM phone WHERE Carrier = "Sprint" OR Carrier = "TMobile"
What is the carrier of the most expensive phone?
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 carrier of the most expensive phone?` to a syntactically-correct PostgreSQL query.
SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1
Show different carriers of phones together with the number of phones with each carrier.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 different carriers of phones together with the number of phones with each carrier.` to a syntactically-correct PostgreSQL query.
SELECT Carrier , COUNT(*) FROM phone GROUP BY Carrier
Show the most frequently used carrier of the phones.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 most frequently used carrier of the phones.` to a syntactically-correct PostgreSQL query.
SELECT Carrier FROM phone GROUP BY Carrier ORDER BY COUNT(*) DESC LIMIT 1
Show the carriers that have both phones with memory smaller than 32 and phones with memory bigger than 64.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 carriers that have both phones with memory smaller than 32 and phones with memory bigger than 64.` to a syntactically-correct PostgreSQL query.
SELECT Carrier FROM phone WHERE Memory_in_G < 32 INTERSECT SELECT Carrier FROM phone WHERE Memory_in_G > 64
Show the names of phones and the districts of markets they are on.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 of phones and the districts of markets they are on.` to a syntactically-correct PostgreSQL query.
SELECT T3.Name , T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID
Show the names of phones and the districts of markets they are on, in ascending order of the ranking of the market.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 of phones and the districts of markets they are on, in ascending order of the ranking of the market.` to a syntactically-correct PostgreSQL query.
SELECT T3.Name , T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID ORDER BY T2.Ranking
Show the names of phones that are on market with number of shops greater than 50.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 of phones that are on market with number of shops greater than 50.` to a syntactically-correct PostgreSQL query.
SELECT T3.Name FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID WHERE T2.Num_of_shops > 50
For each phone, show its names and total number of stocks.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 `For each phone, show its names and total number of stocks.` to a syntactically-correct PostgreSQL query.
SELECT T2.Name , sum(T1.Num_of_stock) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name
Show the names of phones that have total number of stocks bigger than 2000, in descending order of the total number of stocks.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 of phones that have total number of stocks bigger than 2000, in descending order of the total number of stocks.` to a syntactically-correct PostgreSQL query.
SELECT T2.Name FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name HAVING sum(T1.Num_of_stock) >= 2000 ORDER BY sum(T1.Num_of_stock) DESC
List the names of phones that are not on any market.
-- Language PostgreSQL -- Tables: -- Table: phone columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']] -- Table: market columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']] -- Table: phone market columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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 the names of phones that are not on any market.` to a syntactically-correct PostgreSQL query.
SELECT Name FROM phone WHERE Phone_id NOT IN (SELECT Phone_ID FROM phone_market)
How many gas companies are there?
-- Language PostgreSQL -- Tables: -- Table: company columns : [['company id', 'number'], ['rank', 'number'], ['company', 'text'], ['headquarters', 'text'], ['main industry', 'text'], ['sales billion', 'number'], ['profits billion', 'number'], ['assets billion', 'number'], ['market value', 'number']] -- Table: gas station columns : [['station id', 'number'], ['open year', 'number'], ['location', 'text'], ['manager name', 'text'], ['vice manager name', 'text'], ['representative name', 'text']] -- Table: station company columns : [['station id', 'number'], ['company id', 'number'], ['rank of the 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 gas companies are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM company
What is the total number of companies?
-- Language PostgreSQL -- Tables: -- Table: company columns : [['company id', 'number'], ['rank', 'number'], ['company', 'text'], ['headquarters', 'text'], ['main industry', 'text'], ['sales billion', 'number'], ['profits billion', 'number'], ['assets billion', 'number'], ['market value', 'number']] -- Table: gas station columns : [['station id', 'number'], ['open year', 'number'], ['location', 'text'], ['manager name', 'text'], ['vice manager name', 'text'], ['representative name', 'text']] -- Table: station company columns : [['station id', 'number'], ['company id', 'number'], ['rank of the 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 `What is the total number of companies?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM company
List the company name and rank for all companies in the decreasing order of their sales.
-- Language PostgreSQL -- Tables: -- Table: company columns : [['company id', 'number'], ['rank', 'number'], ['company', 'text'], ['headquarters', 'text'], ['main industry', 'text'], ['sales billion', 'number'], ['profits billion', 'number'], ['assets billion', 'number'], ['market value', 'number']] -- Table: gas station columns : [['station id', 'number'], ['open year', 'number'], ['location', 'text'], ['manager name', 'text'], ['vice manager name', 'text'], ['representative name', 'text']] -- Table: station company columns : [['station id', 'number'], ['company id', 'number'], ['rank of the 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 the company name and rank for all companies in the decreasing order of their sales.` to a syntactically-correct PostgreSQL query.
SELECT company , rank FROM company ORDER BY Sales_billion DESC
What is the name and rank of every company ordered by descending number of sales?
-- Language PostgreSQL -- Tables: -- Table: company columns : [['company id', 'number'], ['rank', 'number'], ['company', 'text'], ['headquarters', 'text'], ['main industry', 'text'], ['sales billion', 'number'], ['profits billion', 'number'], ['assets billion', 'number'], ['market value', 'number']] -- Table: gas station columns : [['station id', 'number'], ['open year', 'number'], ['location', 'text'], ['manager name', 'text'], ['vice manager name', 'text'], ['representative name', 'text']] -- Table: station company columns : [['station id', 'number'], ['company id', 'number'], ['rank of the 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 `What is the name and rank of every company ordered by descending number of sales?` to a syntactically-correct PostgreSQL query.
SELECT company , rank FROM company ORDER BY Sales_billion DESC
Show the company name and the main industry for all companies whose headquarters are not from USA.
-- Language PostgreSQL -- Tables: -- Table: company columns : [['company id', 'number'], ['rank', 'number'], ['company', 'text'], ['headquarters', 'text'], ['main industry', 'text'], ['sales billion', 'number'], ['profits billion', 'number'], ['assets billion', 'number'], ['market value', 'number']] -- Table: gas station columns : [['station id', 'number'], ['open year', 'number'], ['location', 'text'], ['manager name', 'text'], ['vice manager name', 'text'], ['representative name', 'text']] -- Table: station company columns : [['station id', 'number'], ['company id', 'number'], ['rank of the 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 company name and the main industry for all companies whose headquarters are not from USA.` to a syntactically-correct PostgreSQL query.
SELECT company , main_industry FROM company WHERE headquarters != 'USA'
What are the companies and main industries of all companies that are not headquartered in the United States?
-- Language PostgreSQL -- Tables: -- Table: company columns : [['company id', 'number'], ['rank', 'number'], ['company', 'text'], ['headquarters', 'text'], ['main industry', 'text'], ['sales billion', 'number'], ['profits billion', 'number'], ['assets billion', 'number'], ['market value', 'number']] -- Table: gas station columns : [['station id', 'number'], ['open year', 'number'], ['location', 'text'], ['manager name', 'text'], ['vice manager name', 'text'], ['representative name', 'text']] -- Table: station company columns : [['station id', 'number'], ['company id', 'number'], ['rank of the 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 `What are the companies and main industries of all companies that are not headquartered in the United States?` to a syntactically-correct PostgreSQL query.
SELECT company , main_industry FROM company WHERE headquarters != 'USA'
Show all company names and headquarters in the descending order of market value.
-- Language PostgreSQL -- Tables: -- Table: company columns : [['company id', 'number'], ['rank', 'number'], ['company', 'text'], ['headquarters', 'text'], ['main industry', 'text'], ['sales billion', 'number'], ['profits billion', 'number'], ['assets billion', 'number'], ['market value', 'number']] -- Table: gas station columns : [['station id', 'number'], ['open year', 'number'], ['location', 'text'], ['manager name', 'text'], ['vice manager name', 'text'], ['representative name', 'text']] -- Table: station company columns : [['station id', 'number'], ['company id', 'number'], ['rank of the 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 company names and headquarters in the descending order of market value.` to a syntactically-correct PostgreSQL query.
SELECT company , headquarters FROM company ORDER BY market_value DESC