Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: What is the description of the color for most products? [/INST]

Output: SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code  =  t2.color_code GROUP BY t2.color_description ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: Return the color description that is most common across all products. [/INST]

Output: SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code  =  t2.color_code GROUP BY t2.color_description ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: What is the description of the color used by least products? [/INST]

Output: SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code  =  t2.color_code GROUP BY t2.color_description ORDER BY count(*) ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: Give the color description that is least common across products. [/INST]

Output: SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code  =  t2.color_code GROUP BY t2.color_description ORDER BY count(*) ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: What is the characteristic name used by most number of the products? [/INST]

Output: SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id  =  t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id  =  t3.characteristic_id GROUP BY t3.characteristic_name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: Return the name of the characteristic that is most common across all products. [/INST]

Output: SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id  =  t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id  =  t3.characteristic_id GROUP BY t3.characteristic_name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names, details and data types of the characteristics which are never used by any product? [/INST]

Output: SELECT characteristic_name ,  other_characteristic_details ,  characteristic_data_type FROM CHARACTERISTICS EXCEPT SELECT t1.characteristic_name ,  t1.other_characteristic_details ,  t1.characteristic_data_type FROM CHARACTERISTICS AS t1 JOIN product_characteristics AS t2 ON t1.characteristic_id  =  t2.characteristic_id;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: Give the names, details, and data types of characteristics that are not found in any product. [/INST]

Output: SELECT characteristic_name ,  other_characteristic_details ,  characteristic_data_type FROM CHARACTERISTICS EXCEPT SELECT t1.characteristic_name ,  t1.other_characteristic_details ,  t1.characteristic_data_type FROM CHARACTERISTICS AS t1 JOIN product_characteristics AS t2 ON t1.characteristic_id  =  t2.characteristic_id;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: What are characteristic names used at least twice across all products? [/INST]

Output: SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id  =  t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id  =  t3.characteristic_id GROUP BY t3.characteristic_name HAVING count(*)  >= 2;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: Give the names of characteristics that are in two or more products? [/INST]

Output: SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id  =  t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id  =  t3.characteristic_id GROUP BY t3.characteristic_name HAVING count(*)  >= 2;


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: How many colors are never used by any product? [/INST]

Output: SELECT count(*) FROM Ref_colors WHERE color_code NOT IN ( SELECT color_code FROM products );


Input:
[INST] Here is a database schema:
Ref_Characteristic_Types :
characteristic_type_code [ TEXT ] primary_key
characteristic_type_description [ TEXT ]

Ref_Colors :
color_code [ TEXT ] primary_key
color_description [ TEXT ]

Ref_Product_Categories :
product_category_code [ TEXT ] primary_key
product_category_description [ TEXT ]
unit_of_measure [ TEXT ]

Characteristics :
characteristic_id [ INT ] primary_key
characteristic_type_code [ TEXT ] Characteristics.characteristic_type_code = Ref_Characteristic_Types.characteristic_type_code
characteristic_data_type [ TEXT ]
characteristic_name [ TEXT ]
other_characteristic_details [ TEXT ]

Products :
product_id [ INT ] primary_key
color_code [ TEXT ] Products.color_code = Ref_Colors.color_code
product_category_code [ TEXT ] Products.product_category_code = Ref_Product_Categories.product_category_code
product_name [ TEXT ]
typical_buying_price [ TEXT ]
typical_selling_price [ TEXT ]
product_description [ TEXT ]
other_product_details [ TEXT ]

Product_Characteristics :
product_id [ INT ] Product_Characteristics.product_id = Products.product_id
characteristic_id [ INT ] Product_Characteristics.characteristic_id = Characteristics.characteristic_id
product_characteristic_value [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of colors that are not used in any products. [/INST]

Output: SELECT count(*) FROM Ref_colors WHERE color_code NOT IN ( SELECT color_code FROM products );


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: How many events are there? [/INST]

Output: SELECT count(*) FROM event;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: List all the event names by year from the most recent to the oldest. [/INST]

Output: SELECT name FROM event ORDER BY YEAR DESC;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: What is the name of the event that happened in the most recent year? [/INST]

Output: SELECT name FROM event ORDER BY YEAR DESC LIMIT 1;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: How many stadiums are there? [/INST]

Output: SELECT count(*) FROM stadium;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the name of the stadium that has the maximum capacity. [/INST]

Output: SELECT name FROM stadium ORDER BY capacity DESC LIMIT 1;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the names of stadiums whose capacity is smaller than the average capacity. [/INST]

Output: SELECT name FROM stadium WHERE capacity  <  (SELECT avg(capacity) FROM stadium);


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the country that has the most stadiums. [/INST]

Output: SELECT country FROM stadium GROUP BY country ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Which country has at most 3 stadiums listed? [/INST]

Output: SELECT country FROM stadium GROUP BY country HAVING count(*)  <=  3;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Which country has both stadiums with capacity greater than 60000 and stadiums with capacity less than 50000? [/INST]

Output: SELECT country FROM stadium WHERE capacity  >  60000 INTERSECT SELECT country FROM stadium WHERE capacity  <  50000;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: How many cities have a stadium that was opened before the year of 2006? [/INST]

Output: SELECT count(DISTINCT city) FROM stadium WHERE opening_year  <  2006;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: How many stadiums does each country have? [/INST]

Output: SELECT country ,  count(*) FROM stadium GROUP BY country;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Which countries do not have a stadium that was opened after 2006? [/INST]

Output: SELECT country FROM stadium EXCEPT SELECT country FROM stadium WHERE opening_year  >  2006;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: How many stadiums are not in country "Russia"? [/INST]

Output: SELECT count(*) FROM stadium WHERE country != 'Russia';


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the names of all swimmers, sorted by their 100 meter scores in ascending order. [/INST]

Output: SELECT name FROM swimmer ORDER BY meter_100;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: How many different countries are all the swimmers from? [/INST]

Output: SELECT count(DISTINCT nationality) FROM swimmer;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: List countries that have more than one swimmer. [/INST]

Output: SELECT nationality ,  count(*) FROM swimmer GROUP BY nationality HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find all 200 meter and 300 meter results of swimmers with nationality "Australia". [/INST]

Output: SELECT meter_200 ,  meter_300 FROM swimmer WHERE nationality  =  'Australia';


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the names of swimmers who has a result of "win". [/INST]

Output: SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id  =  t2.swimmer_id WHERE RESULT  =  'Win';


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: What is the name of the stadium which held the most events? [/INST]

Output: SELECT t1.name FROM stadium AS t1 JOIN event AS t2 ON t1.id  =  t2.stadium_id GROUP BY t2.stadium_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the name and capacity of the stadium where the event named "World Junior" happened. [/INST]

Output: SELECT t1.name ,  t1.capacity FROM stadium AS t1 JOIN event AS t2 ON t1.id  =  t2.stadium_id WHERE t2.name  =  'World Junior';


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the names of stadiums which have never had any event. [/INST]

Output: SELECT name FROM stadium WHERE id NOT IN (SELECT stadium_id FROM event);


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the name of the swimmer who has the most records. [/INST]

Output: SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id  =  t2.swimmer_id GROUP BY t2.swimmer_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the name of the swimmer who has at least 2 records. [/INST]

Output: SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id  =  t2.swimmer_id GROUP BY t2.swimmer_id HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the name and nationality of the swimmer who has won (i.e., has a result of "win") more than 1 time. [/INST]

Output: SELECT t1.name ,  t1.nationality FROM swimmer AS t1 JOIN record AS t2 ON t1.id  =  t2.swimmer_id WHERE RESULT  =  'Win' GROUP BY t2.swimmer_id HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the names of the swimmers who have no record. [/INST]

Output: SELECT name FROM swimmer WHERE id NOT IN (SELECT swimmer_id FROM record);


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the names of the swimmers who have both "win" and "loss" results in the record. [/INST]

Output: SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id  =  t2.swimmer_id WHERE RESULT  =  'Win' INTERSECT SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id  =  t2.swimmer_id WHERE RESULT  =  'Loss';


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the names of stadiums that some Australian swimmers have been to. [/INST]

Output: SELECT t4.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id  =  t2.swimmer_id JOIN event AS t3 ON t2.event_id  =  t3.id JOIN stadium AS t4 ON t4.id  =  t3.stadium_id WHERE t1.nationality  =  'Australia';


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find the names of stadiums that the most swimmers have been to. [/INST]

Output: SELECT t3.name FROM record AS t1 JOIN event AS t2 ON t1.event_id  =  t2.id JOIN stadium AS t3 ON t3.id  =  t2.stadium_id GROUP BY t2.stadium_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: Find all details for each swimmer. [/INST]

Output: SELECT * FROM swimmer;


Input:
[INST] Here is a database schema:
swimmer :
ID [ INT ] primary_key
name [ TEXT ]
Nationality [ TEXT ]
meter_100 [ INT ]
meter_200 [ TEXT ]
meter_300 [ TEXT ]
meter_400 [ TEXT ]
meter_500 [ TEXT ]
meter_600 [ TEXT ]
meter_700 [ TEXT ]
Time [ TEXT ]

stadium :
ID [ INT ] primary_key
name [ TEXT ]
Capacity [ INT ]
City [ TEXT ]
Country [ TEXT ]
Opening_year [ INT ]

event :
ID [ INT ] primary_key
Name [ TEXT ]
Stadium_ID [ INT ] event.Stadium_ID = stadium.ID
Year [ TEXT ]

record :
ID [ INT ]
Result [ TEXT ]
Swimmer_ID [ INT ] primary_key record.Swimmer_ID = swimmer.ID
Event_ID [ INT ] record.Event_ID = event.ID

Please write me a SQL statement that answers the following question: What is the average capacity of the stadiums that were opened in year 2005? [/INST]

Output: SELECT avg(capacity) FROM stadium WHERE opening_year  =  2005;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: How many railways are there? [/INST]

Output: SELECT count(*) FROM railway;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: List the builders of railways in ascending alphabetical order. [/INST]

Output: SELECT Builder FROM railway ORDER BY Builder ASC;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: List the wheels and locations of the railways. [/INST]

Output: SELECT Wheels ,  LOCATION FROM railway;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: What is the maximum level of managers in countries that are not "Australia"? [/INST]

Output: SELECT max(LEVEL) FROM manager WHERE Country != "Australia	";


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: What is the average age for all managers? [/INST]

Output: SELECT avg(Age) FROM manager;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of managers in ascending order of level? [/INST]

Output: SELECT Name FROM manager ORDER BY LEVEL ASC;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names and arrival times of trains? [/INST]

Output: SELECT Name ,  Arrival FROM train;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the oldest manager? [/INST]

Output: SELECT Name FROM manager ORDER BY Age DESC LIMIT 1;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of trains and locations of railways they are in. [/INST]

Output: SELECT T2.Name ,  T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show the builder of railways associated with the trains named "Andaman Exp". [/INST]

Output: SELECT T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID WHERE T2.Name  =  "Andaman Exp";


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show id and location of railways that are associated with more than one train. [/INST]

Output: SELECT T2.Railway_ID ,  T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID GROUP BY T2.Railway_ID HAVING COUNT(*)  >  1;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show the id and builder of the railway that are associated with the most trains. [/INST]

Output: SELECT T2.Railway_ID ,  T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID  =  T2.Railway_ID GROUP BY T2.Railway_ID ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show different builders of railways, along with the corresponding number of railways using each builder. [/INST]

Output: SELECT Builder ,  COUNT(*) FROM railway GROUP BY Builder;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show the most common builder of railways. [/INST]

Output: SELECT Builder FROM railway GROUP BY Builder ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show different locations of railways along with the corresponding number of railways at each location. [/INST]

Output: SELECT LOCATION ,  COUNT(*) FROM railway GROUP BY LOCATION;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show the locations that have more than one railways. [/INST]

Output: SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*)  >  1;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: List the object number of railways that do not have any trains. [/INST]

Output: SELECT ObjectNumber FROM railway WHERE Railway_ID NOT IN (SELECT Railway_ID FROM train);


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show the countries that have both managers of age above 50 and managers of age below 46. [/INST]

Output: SELECT Country FROM manager WHERE Age  >  50 INTERSECT SELECT Country FROM manager WHERE Age  <  46;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show the distinct countries of managers. [/INST]

Output: SELECT DISTINCT Country FROM manager;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show the working years of managers in descending order of their level. [/INST]

Output: SELECT Working_year_starts FROM manager ORDER BY LEVEL DESC;


Input:
[INST] Here is a database schema:
railway :
Railway_ID [ INT ] primary_key
Railway [ TEXT ]
Builder [ TEXT ]
Built [ TEXT ]
Wheels [ TEXT ]
Location [ TEXT ]
ObjectNumber [ TEXT ]

train :
Train_ID [ INT ] primary_key
Train_Num [ TEXT ]
Name [ TEXT ]
From [ TEXT ]
Arrival [ TEXT ]
Railway_ID [ INT ] train.Railway_ID = railway.Railway_ID

manager :
Manager_ID [ INT ] primary_key
Name [ TEXT ]
Country [ TEXT ]
Working_year_starts [ TEXT ]
Age [ INT ]
Level [ INT ]

railway_manage :
Railway_ID [ INT ] primary_key railway_manage.Railway_ID = railway.Railway_ID
Manager_ID [ INT ] railway_manage.Manager_ID = manager.Manager_ID
From_Year [ TEXT ]

Please write me a SQL statement that answers the following question: Show the countries that have managers of age above 50 or below 46. [/INST]

Output: SELECT Country FROM manager WHERE Age  >  50 OR Age  <  46;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: How many addresses are there in country USA? [/INST]

Output: SELECT count(*) FROM addresses WHERE country  =  'USA';


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show all distinct cities in the address record. [/INST]

Output: SELECT DISTINCT city FROM addresses;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show each state and the number of addresses in each state. [/INST]

Output: SELECT state_province_county ,  count(*) FROM addresses GROUP BY state_province_county;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show names and phones of customers who do not have address information. [/INST]

Output: SELECT customer_name ,  customer_phone FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM customer_address_history);


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show the name of the customer who has the most orders. [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show the product type codes which have at least two products. [/INST]

Output: SELECT product_type_code FROM products GROUP BY product_type_code HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of customers who have both an order in completed status and an order in part status. [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T2.order_status_code  =  'Completed' INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T2.order_status_code  =  'Part';


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show the name, phone, and payment method code for all customers in descending order of customer number. [/INST]

Output: SELECT customer_name ,  customer_phone ,  payment_method_code FROM customers ORDER BY customer_number DESC;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show the product name and total order quantity for each product. [/INST]

Output: SELECT T1.product_name ,  sum(T2.order_quantity) FROM products AS T1 JOIN order_items AS T2 ON T1.product_id  =  T2.product_id GROUP BY T1.product_id;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show the minimum, maximum, average price for all products. [/INST]

Output: SELECT min(product_price) ,  max(product_price) ,  avg(product_price) FROM products;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: How many products have a price higher than the average? [/INST]

Output: SELECT count(*) FROM products WHERE product_price  >  (SELECT avg(product_price) FROM products);


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show the customer name, customer address city, date from, and date to for each customer address history. [/INST]

Output: SELECT T2.customer_name ,  T3.city ,  T1.date_from ,  T1.date_to FROM customer_address_history AS T1 JOIN customers AS T2 ON T1.customer_id  =  T2.customer_id JOIN addresses AS T3 ON T1.address_id  =  T3.address_id;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of customers who use Credit Card payment method and have more than 2 orders. [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T1.payment_method_code  =  'Credit Card' GROUP BY T1.customer_id HAVING count(*)  >  2;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: What are the name and phone of the customer with the most ordered product quantity? [/INST]

Output: SELECT  T1.customer_name ,  T1.customer_phone FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id JOIN order_items AS T3 ON T3.order_id  =  T2.order_id GROUP BY T1.customer_id ORDER BY sum(T3.order_quantity) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
line_1_number_building [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_number [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Contacts :
contact_id [ INT ] primary_key
customer_id [ INT ]
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
contact_phone [ TEXT ]

Customer_Address_History :
customer_id [ INT ] Customer_Address_History.customer_id = Customers.customer_id
address_id [ INT ] Customer_Address_History.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_date [ TEXT ]
order_status_code [ TEXT ]

Order_Items :
order_item_id [ INT ]
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id
order_quantity [ TEXT ]

Please write me a SQL statement that answers the following question: Show the product type and name for the products with price higher than 1000 or lower than 500. [/INST]

Output: SELECT product_type_code ,  product_name FROM products WHERE product_price  >  1000 OR product_price  <  500;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of dorms only for female (F gender). [/INST]

Output: SELECT dorm_name FROM dorm WHERE gender  =  'F';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the names of the all-female dorms? [/INST]

Output: SELECT dorm_name FROM dorm WHERE gender  =  'F';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of dorms that can accommodate more than 300 students. [/INST]

Output: SELECT dorm_name FROM dorm WHERE student_capacity  >  300;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the names of all the dorms that can accomdate more than 300 students? [/INST]

Output: SELECT dorm_name FROM dorm WHERE student_capacity  >  300;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many female students (sex is F) whose age is below 25? [/INST]

Output: SELECT count(*) FROM student WHERE sex  =  'F' AND age  <  25;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many girl students who are younger than 25? [/INST]

Output: SELECT count(*) FROM student WHERE sex  =  'F' AND age  <  25;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the first name of students who is older than 20. [/INST]

Output: SELECT fname FROM student WHERE age  >  20;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the first names of all students who are older than 20? [/INST]

Output: SELECT fname FROM student WHERE age  >  20;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the first name of students living in city PHL whose age is between 20 and 25. [/INST]

Output: SELECT fname FROM student WHERE city_code  =  'PHL' AND age BETWEEN 20 AND 25;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the first name of the students who are in age 20 to 25 and living in PHL city? [/INST]

Output: SELECT fname FROM student WHERE city_code  =  'PHL' AND age BETWEEN 20 AND 25;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many dorms are there? [/INST]

Output: SELECT count(*) FROM dorm;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many dorms are in the database? [/INST]

Output: SELECT count(*) FROM dorm;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of distinct amenities. [/INST]

Output: SELECT count(*) FROM dorm_amenity;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many diffrent dorm amenities are there? [/INST]

Output: SELECT count(*) FROM dorm_amenity;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the total capacity of all dorms. [/INST]

Output: SELECT sum(student_capacity) FROM dorm;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the total student capacity of all dorms? [/INST]

Output: SELECT sum(student_capacity) FROM dorm;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many students are there? [/INST]

Output: SELECT count(*) FROM student;