brief_instruction
stringlengths
16
224
instruction
stringlengths
687
8.77k
output
stringlengths
18
577
What are the first names of the faculty members playing both Canoeing and Kayaking?
-- Language PostgreSQL -- Tables: -- Table: activity columns : [['activity id', 'number'], ['activity name', 'text']] -- Table: participates in columns : [['student id', 'number'], ['activity id', 'number']] -- Table: faculty participates in columns : [['faculty id', 'number'], ['activity id', 'number']] -- Table: student columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']] -- Table: faculty columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', '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 names of the faculty members playing both Canoeing and Kayaking?` to a syntactically-correct PostgreSQL query.
SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' INTERSECT SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Kayaking'
Find the ids of the students who participate in Canoeing and Kayaking.
-- Language PostgreSQL -- Tables: -- Table: activity columns : [['activity id', 'number'], ['activity name', 'text']] -- Table: participates in columns : [['student id', 'number'], ['activity id', 'number']] -- Table: faculty participates in columns : [['faculty id', 'number'], ['activity id', 'number']] -- Table: student columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']] -- Table: faculty columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', '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 `Find the ids of the students who participate in Canoeing and Kayaking.` to a syntactically-correct PostgreSQL query.
SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Canoeing' INTERSECT SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Kayaking'
Which students participate in both Canoeing and Kayaking as their activities? Tell me their student ids.
-- Language PostgreSQL -- Tables: -- Table: activity columns : [['activity id', 'number'], ['activity name', 'text']] -- Table: participates in columns : [['student id', 'number'], ['activity id', 'number']] -- Table: faculty participates in columns : [['faculty id', 'number'], ['activity id', 'number']] -- Table: student columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']] -- Table: faculty columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', '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 `Which students participate in both Canoeing and Kayaking as their activities? Tell me their student ids.` to a syntactically-correct PostgreSQL query.
SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Canoeing' INTERSECT SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Kayaking'
Find the name of the airport in the city of Goroka.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the name of the airport in the city of Goroka.` to a syntactically-correct PostgreSQL query.
SELECT name FROM airports WHERE city = 'Goroka'
What are the names of the airports in the city of Goroka?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 the airports in the city of Goroka?` to a syntactically-correct PostgreSQL query.
SELECT name FROM airports WHERE city = 'Goroka'
Find the name, city, country, and altitude (or elevation) of the airports in the city of New York.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the name, city, country, and altitude (or elevation) of the airports in the city of New York.` to a syntactically-correct PostgreSQL query.
SELECT name , city , country , elevation FROM airports WHERE city = 'New York'
What is the name, city, country, and elevation for every airport in the city of New York?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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, city, country, and elevation for every airport in the city of New York?` to a syntactically-correct PostgreSQL query.
SELECT name , city , country , elevation FROM airports WHERE city = 'New York'
How many airlines are there?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airlines are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airlines
What is the total number of airlines?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 total number of airlines?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airlines
How many airlines does Russia has?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airlines does Russia has?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airlines WHERE country = 'Russia'
What is the number of airlines based in Russia?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 number of airlines based in Russia?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airlines WHERE country = 'Russia'
What is the maximum elevation of all airports in the country of Iceland?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 elevation of all airports in the country of Iceland?` to a syntactically-correct PostgreSQL query.
SELECT max(elevation) FROM airports WHERE country = 'Iceland'
What is the highest elevation of an airport in the country of Iceland?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 highest elevation of an airport in the country of Iceland?` to a syntactically-correct PostgreSQL query.
SELECT max(elevation) FROM airports WHERE country = 'Iceland'
Find the name of the airports located in Cuba or Argentina.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the name of the airports located in Cuba or Argentina.` to a syntactically-correct PostgreSQL query.
SELECT name FROM airports WHERE country = 'Cuba' OR country = 'Argentina'
What are the names of all airports in Cuba or Argentina?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 all airports in Cuba or Argentina?` to a syntactically-correct PostgreSQL query.
SELECT name FROM airports WHERE country = 'Cuba' OR country = 'Argentina'
Find the country of the airlines whose name starts with 'Orbit'.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the country of the airlines whose name starts with 'Orbit'.` to a syntactically-correct PostgreSQL query.
SELECT country FROM airlines WHERE name LIKE 'Orbit%'
What are the countries of all airlines whose names start with Orbit?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 countries of all airlines whose names start with Orbit?` to a syntactically-correct PostgreSQL query.
SELECT country FROM airlines WHERE name LIKE 'Orbit%'
Find the name of airports whose altitude is between -50 and 50.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the name of airports whose altitude is between -50 and 50.` to a syntactically-correct PostgreSQL query.
SELECT name FROM airports WHERE elevation BETWEEN -50 AND 50
What are the names of all airports whose elevation is between -50 and 50?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 all airports whose elevation is between -50 and 50?` to a syntactically-correct PostgreSQL query.
SELECT name FROM airports WHERE elevation BETWEEN -50 AND 50
Which country is the airport that has the highest altitude located in?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Which country is the airport that has the highest altitude located in?` to a syntactically-correct PostgreSQL query.
SELECT country FROM airports ORDER BY elevation DESC LIMIT 1
What is the country of the airport with the highest elevation?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 country of the airport with the highest elevation?` to a syntactically-correct PostgreSQL query.
SELECT country FROM airports ORDER BY elevation DESC LIMIT 1
Find the number of airports whose name contain the word 'International'.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the number of airports whose name contain the word 'International'.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airports WHERE name LIKE '%International%'
How many airports' names have the word Interanation in them?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airports' names have the word Interanation in them?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airports WHERE name LIKE '%International%'
How many different cities do have some airport in the country of Greenland?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 cities do have some airport in the country of Greenland?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT city) FROM airports WHERE country = 'Greenland'
In how many cities are there airports in the country of Greenland?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `In how many cities are there airports in the country of Greenland?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT city) FROM airports WHERE country = 'Greenland'
Find the number of routes operated by American Airlines.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the number of routes operated by American Airlines.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'
How many routes does American Airlines operate?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 routes does American Airlines operate?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'
Find the number of routes whose destination airports are in Canada.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the number of routes whose destination airports are in Canada.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE country = 'Canada'
How many routes end in a Canadian airport?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 routes end in a Canadian airport?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE country = 'Canada'
Find the name, city, and country of the airport that has the lowest altitude.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the name, city, and country of the airport that has the lowest altitude.` to a syntactically-correct PostgreSQL query.
SELECT name , city , country FROM airports ORDER BY elevation LIMIT 1
What is the name, city, and country of the airport with the lowest altitude?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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, city, and country of the airport with the lowest altitude?` to a syntactically-correct PostgreSQL query.
SELECT name , city , country FROM airports ORDER BY elevation LIMIT 1
Find the name, city, and country of the airport that has the highest latitude.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the name, city, and country of the airport that has the highest latitude.` to a syntactically-correct PostgreSQL query.
SELECT name , city , country FROM airports ORDER BY elevation DESC LIMIT 1
What is the name, city, and country of the airport with the highest elevation?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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, city, and country of the airport with the highest elevation?` to a syntactically-correct PostgreSQL query.
SELECT name , city , country FROM airports ORDER BY elevation DESC LIMIT 1
Find the name and city of the airport which is the destination of the most number of routes.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the name and city of the airport which is the destination of the most number of routes.` to a syntactically-correct PostgreSQL query.
SELECT T1.name , T1.city , T2.dst_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid GROUP BY T2.dst_apid ORDER BY count(*) DESC LIMIT 1
What is the name and city of the airport that the most routes end at?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 and city of the airport that the most routes end at?` to a syntactically-correct PostgreSQL query.
SELECT T1.name , T1.city , T2.dst_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid GROUP BY T2.dst_apid ORDER BY count(*) DESC LIMIT 1
Find the names of the top 10 airlines that operate the most number of routes.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the names of the top 10 airlines that operate the most number of routes.` to a syntactically-correct PostgreSQL query.
SELECT T1.name , T2.alid FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T2.alid ORDER BY count(*) DESC LIMIT 10
For the airline ids with the top 10 most routes operated, what are their names?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 the airline ids with the top 10 most routes operated, what are their names?` to a syntactically-correct PostgreSQL query.
SELECT T1.name , T2.alid FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T2.alid ORDER BY count(*) DESC LIMIT 10
Find the name and city of the airport which is the source for the most number of flight routes.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the name and city of the airport which is the source for the most number of flight routes.` to a syntactically-correct PostgreSQL query.
SELECT T1.name , T1.city , T2.src_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T2.src_apid ORDER BY count(*) DESC LIMIT 1
What is the name and city of the airport from most of the routes start?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 and city of the airport from most of the routes start?` to a syntactically-correct PostgreSQL query.
SELECT T1.name , T1.city , T2.src_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T2.src_apid ORDER BY count(*) DESC LIMIT 1
Find the number of different airports which are the destinations of the American Airlines.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the number of different airports which are the destinations of the American Airlines.` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'
What is the number of different different airports that are destinations for American Airlines?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 number of different different airports that are destinations for American Airlines?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'
Which countries has the most number of airlines?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Which countries has the most number of airlines?` to a syntactically-correct PostgreSQL query.
SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1
What is the name of the country with the most number of home airlines?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 country with the most number of home airlines?` to a syntactically-correct PostgreSQL query.
SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1
Which countries has the most number of airlines whose active status is 'Y'?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Which countries has the most number of airlines whose active status is 'Y'?` to a syntactically-correct PostgreSQL query.
SELECT country FROM airlines WHERE active = 'Y' GROUP BY country ORDER BY count(*) DESC LIMIT 1
What are the countries with the most airlines whose active status is Y?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 countries with the most airlines whose active status is Y?` to a syntactically-correct PostgreSQL query.
SELECT country FROM airlines WHERE active = 'Y' GROUP BY country ORDER BY count(*) DESC LIMIT 1
List all countries and their number of airlines in the descending order of number of airlines.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 all countries and their number of airlines in the descending order of number of airlines.` to a syntactically-correct PostgreSQL query.
SELECT country , count(*) FROM airlines GROUP BY country ORDER BY count(*) DESC
How many airlines operate out of each country in descending order?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airlines operate out of each country in descending order?` to a syntactically-correct PostgreSQL query.
SELECT country , count(*) FROM airlines GROUP BY country ORDER BY count(*) DESC
How many airports are there per country? Order the countries by decreasing number of airports.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airports are there per country? Order the countries by decreasing number of airports.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , country FROM airports GROUP BY country ORDER BY count(*) DESC
What is the number of airports per country, ordered from most to least?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 number of airports per country, ordered from most to least?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , country FROM airports GROUP BY country ORDER BY count(*) DESC
How many airports are there per city in the United States? Order the cities by decreasing number of airports.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airports are there per city in the United States? Order the cities by decreasing number of airports.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , city FROM airports WHERE country = 'United States' GROUP BY city ORDER BY count(*) DESC
How many airports are there per city in the US ordered from most to least?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airports are there per city in the US ordered from most to least?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , city FROM airports WHERE country = 'United States' GROUP BY city ORDER BY count(*) DESC
Return the cities with more than 3 airports in the United States.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Return the cities with more than 3 airports in the United States.` to a syntactically-correct PostgreSQL query.
SELECT city FROM airports WHERE country = 'United States' GROUP BY city HAVING count(*) > 3
What is the number of cities in the United States with more than 3 airports?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 number of cities in the United States with more than 3 airports?` to a syntactically-correct PostgreSQL query.
SELECT city FROM airports WHERE country = 'United States' GROUP BY city HAVING count(*) > 3
How many cities are there that have more than 3 airports?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 cities are there that have more than 3 airports?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM (SELECT city FROM airports GROUP BY city HAVING count(*) > 3)
What is the count of cities with more than 3 airports?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 count of cities with more than 3 airports?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM (SELECT city FROM airports GROUP BY city HAVING count(*) > 3)
List the cities which have more than one airport and number of airports.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 cities which have more than one airport and number of airports.` to a syntactically-correct PostgreSQL query.
SELECT city , count(*) FROM airports GROUP BY city HAVING count(*) > 1
What are the names of all cities with more than one airport and how many airports do they have?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 all cities with more than one airport and how many airports do they have?` to a syntactically-correct PostgreSQL query.
SELECT city , count(*) FROM airports GROUP BY city HAVING count(*) > 1
List the cities which have more than 2 airports sorted by the number of airports.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 cities which have more than 2 airports sorted by the number of airports.` to a syntactically-correct PostgreSQL query.
SELECT city FROM airports GROUP BY city HAVING count(*) > 2 ORDER BY count(*)
What are the cities that have more than 2 airports sorted by number of airports?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 cities that have more than 2 airports sorted by number of airports?` to a syntactically-correct PostgreSQL query.
SELECT city FROM airports GROUP BY city HAVING count(*) > 2 ORDER BY count(*)
Find the number of routes for each source airport and the airport name.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the number of routes for each source airport and the airport name.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name
For each airport name, how many routes start at that airport?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airport name, how many routes start at that airport?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name
Find the number of routes and airport name for each source airport, order the results by decreasing number of routes.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the number of routes and airport name for each source airport, order the results by decreasing number of routes.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name ORDER BY count(*) DESC
For each airport name, how many routes start at that airport, ordered from most to least?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airport name, how many routes start at that airport, ordered from most to least?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name ORDER BY count(*) DESC
Find the average elevation of all airports for each country.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the average elevation of all airports for each country.` to a syntactically-correct PostgreSQL query.
SELECT avg(elevation) , country FROM airports GROUP BY country
For each country, what is the average elevation of that country's airports?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 country, what is the average elevation of that country's airports?` to a syntactically-correct PostgreSQL query.
SELECT avg(elevation) , country FROM airports GROUP BY country
Find the cities which have exactly two airports.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the cities which have exactly two airports.` to a syntactically-correct PostgreSQL query.
SELECT city FROM airports GROUP BY city HAVING count(*) = 2
What are the cities with exactly two airports?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 cities with exactly two airports?` to a syntactically-correct PostgreSQL query.
SELECT city FROM airports GROUP BY city HAVING count(*) = 2
For each country and airline name, how many routes are there?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 country and airline name, how many routes are there?` to a syntactically-correct PostgreSQL query.
SELECT T1.country , T1.name , count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.country , T1.name
What is the total number of routes for each country and airline in that country?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 total number of routes for each country and airline in that country?` to a syntactically-correct PostgreSQL query.
SELECT T1.country , T1.name , count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.country , T1.name
Find the number of routes with destination airports in Italy.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the number of routes with destination airports in Italy.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid WHERE T2.country = 'Italy'
What is the number of routes whose destinations are Italian airports?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 number of routes whose destinations are Italian airports?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid WHERE T2.country = 'Italy'
Return the number of routes with destination airport in Italy operated by the airline with name 'American Airlines'.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Return the number of routes with destination airport in Italy operated by the airline with name 'American Airlines'.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid JOIN airlines AS T3 ON T1.alid = T3.alid WHERE T2.country = 'Italy' AND T3.name = 'American Airlines'
What is the number of routes operated by the airline American Airlines whose destinations are in Italy?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 number of routes operated by the airline American Airlines whose destinations are in Italy?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid JOIN airlines AS T3 ON T1.alid = T3.alid WHERE T2.country = 'Italy' AND T3.name = 'American Airlines'
Find the number of routes that have destination John F Kennedy International Airport.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the number of routes that have destination John F Kennedy International Airport.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.name = 'John F Kennedy International Airport'
What is the number of routes that end at John F Kennedy International Airport?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 number of routes that end at John F Kennedy International Airport?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.name = 'John F Kennedy International Airport'
Find the number of routes from the United States to Canada.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the number of routes from the United States to Canada.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')
How many routes go from the United States to Canada?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 routes go from the United States to Canada?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')
Find the id of routes whose source and destination airports are in the United States.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the id of routes whose source and destination airports are in the United States.` to a syntactically-correct PostgreSQL query.
SELECT rid FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'United States') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')
What is the id of the routes whose source and destination airports are in the United States?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 routes whose source and destination airports are in the United States?` to a syntactically-correct PostgreSQL query.
SELECT rid FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'United States') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')
Find the name of airline which runs the most number of routes.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the name of airline which runs the most number of routes.` to a syntactically-correct PostgreSQL query.
SELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1
What is the name of the airline with the most routes?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airline with the most routes?` to a syntactically-correct PostgreSQL query.
SELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1
Find the busiest source airport that runs most number of routes in China.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the busiest source airport that runs most number of routes in China.` to a syntactically-correct PostgreSQL query.
SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1
What is the name of the airport with the most number of routes that start in China?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airport with the most number of routes that start in China?` to a syntactically-correct PostgreSQL query.
SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1
Find the busiest destination airport that runs most number of routes in China.
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 `Find the busiest destination airport that runs most number of routes in China.` to a syntactically-correct PostgreSQL query.
SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1
What is the name of the airport that is the destination of the most number of routes that start in China?
-- Language PostgreSQL -- Tables: -- Table: routes columns : [['route id', 'number'], ['destination airport id', 'number'], ['destination airport', 'text'], ['source airport id', 'number'], ['source airport', 'text'], ['airline id', 'number'], ['airline', 'text'], ['code share', 'text']] -- Table: airports columns : [['airport id', 'number'], ['name', 'text'], ['city', 'text'], ['country', 'text'], ['x', 'number'], ['y', 'number'], ['elevation', 'number'], ['iata', 'text'], ['icao', 'text']] -- Table: airlines columns : [['airline id', 'number'], ['name', 'text'], ['iata', 'text'], ['icao', 'text'], ['call sign', 'text'], ['country', 'text'], ['active', '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 airport that is the destination of the most number of routes that start in China?` to a syntactically-correct PostgreSQL query.
SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1
What is the id of the most recent order?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the id of the most recent order?` to a syntactically-correct PostgreSQL query.
SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1
Find the id of the order made most recently.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the id of the order made most recently.` to a syntactically-correct PostgreSQL query.
SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1
what are the order id and customer id of the oldest order?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `what are the order id and customer id of the oldest order?` to a syntactically-correct PostgreSQL query.
SELECT order_id , customer_id FROM orders ORDER BY date_order_placed LIMIT 1
Find the order id and customer id associated with the oldest order.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the order id and customer id associated with the oldest order.` to a syntactically-correct PostgreSQL query.
SELECT order_id , customer_id FROM orders ORDER BY date_order_placed LIMIT 1
Find the id of the order whose shipment tracking number is "3452".
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the id of the order whose shipment tracking number is "3452".` to a syntactically-correct PostgreSQL query.
SELECT order_id FROM shipments WHERE shipment_tracking_number = "3452"
Which order's shipment tracking number is "3452"? Give me the id of the order.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which order's shipment tracking number is "3452"? Give me the id of the order.` to a syntactically-correct PostgreSQL query.
SELECT order_id FROM shipments WHERE shipment_tracking_number = "3452"
Find the ids of all the order items whose product id is 11.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the ids of all the order items whose product id is 11.` to a syntactically-correct PostgreSQL query.
SELECT order_item_id FROM order_items WHERE product_id = 11
Find all the order items whose product id is 11. What are the order item ids?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find all the order items whose product id is 11. What are the order item ids?` to a syntactically-correct PostgreSQL query.
SELECT order_item_id FROM order_items WHERE product_id = 11
List the name of all the distinct customers who have orders with status "Packing".
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the name of all the distinct customers who have orders with status "Packing".` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing"
Which customers have orders with status "Packing"? Give me the customer names.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which customers have orders with status "Packing"? Give me the customer names.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing"
Find the details of all the distinct customers who have orders with status "On Road".
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the details of all the distinct customers who have orders with status "On Road".` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road"
What are the distinct customers who have orders with status "On Road"? Give me the customer details?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the distinct customers who have orders with status "On Road"? Give me the customer details?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road"
What is the name of the customer who has the most orders?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the name of the customer who has the most orders?` to a syntactically-correct PostgreSQL query.
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
Which customer made the most orders? Find the customer name.
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which customer made the most orders? Find the customer name.` to a syntactically-correct PostgreSQL query.
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1
What is the customer id of the customer who has the most orders?
-- Language PostgreSQL -- Tables: -- Table: customers columns : [['customer id', 'number'], ['customer name', 'text'], ['customer details', 'text']] -- Table: invoices columns : [['invoice number', 'number'], ['invoice date', 'time'], ['invoice details', 'text']] -- Table: orders columns : [['order id', 'number'], ['customer id', 'number'], ['order status', 'text'], ['date order placed', 'time'], ['order details', 'text']] -- Table: products columns : [['product id', 'number'], ['product name', 'text'], ['product details', 'text']] -- Table: order items columns : [['order item id', 'number'], ['product id', 'number'], ['order id', 'number'], ['order item status', 'text'], ['order item details', 'text']] -- Table: shipments columns : [['shipment id', 'number'], ['order id', 'number'], ['invoice number', 'number'], ['shipment tracking number', 'text'], ['shipment date', 'time'], ['other shipment details', 'text']] -- Table: shipment items columns : [['shipment id', 'number'], ['order item id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the customer id of the customer who has the most orders?` to a syntactically-correct PostgreSQL query.
SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1