Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_name [ TEXT ]
customer_details [ TEXT ]

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which customers have made at least two orders? Give me each customer name and number of orders made. [/INST]

Output: SELECT T2.customer_name ,  count(*) FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_name [ TEXT ]
customer_details [ TEXT ]

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the name of the customers who have at most two orders. [/INST]

Output: SELECT T2.customer_name FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  <=  2;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_name [ TEXT ]
customer_details [ TEXT ]

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What are the names of the customers who have made two or less orders? [/INST]

Output: SELECT T2.customer_name FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  <=  2;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_name [ TEXT ]
customer_details [ TEXT ]

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: List the names of the customers who have once bought product "food". [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T4.product_name = "food" GROUP BY T1.customer_id HAVING count(*)  >=  1;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_name [ TEXT ]
customer_details [ TEXT ]

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What are the names of the customers who bought product "food" at least once? [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T4.product_name = "food" GROUP BY T1.customer_id HAVING count(*)  >=  1;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_name [ TEXT ]
customer_details [ TEXT ]

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: List the names of customers who have once canceled the purchase of the product "food" (the item status is "Cancel"). [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T3.order_item_status = "Cancel" AND T4.product_name = "food" GROUP BY T1.customer_id HAVING count(*)  >=  1;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_name [ TEXT ]
customer_details [ TEXT ]

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which customers have ever canceled the purchase of the product "food" (the item status is "Cancel")? [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T3.order_item_status = "Cancel" AND T4.product_name = "food" GROUP BY T1.customer_id HAVING count(*)  >=  1;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

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

Output: SELECT count(*) FROM architect WHERE gender  =  'female';


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: List the name, nationality and id of all male architects ordered by their names lexicographically. [/INST]

Output: SELECT name ,  nationality ,  id FROM architect WHERE gender  =  'male' ORDER BY name;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What is the maximum length in meters for the bridges and what are the architects' names? [/INST]

Output: SELECT max(T1.length_meters) ,  T2.name FROM bridge AS T1 JOIN architect AS T2 ON T1.architect_id  =  T2.id;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What is the average length in feet of the bridges? [/INST]

Output: SELECT avg(length_feet) FROM bridge;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names and year of construction for the mills of 'Grondzeiler' type? [/INST]

Output: SELECT name ,  built_year FROM mill WHERE TYPE  =  'Grondzeiler';


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct names and nationalities of the architects who have ever built a mill? [/INST]

Output: SELECT DISTINCT T1.name ,  T1.nationality FROM architect AS T1 JOIN mill AS t2 ON T1.id  =  T2.architect_id;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of the mills which are not located in 'Donceel'? [/INST]

Output: SELECT name FROM mill WHERE LOCATION != 'Donceel';


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct types of mills that are built by American or Canadian architects? [/INST]

Output: SELECT DISTINCT T1.type FROM mill AS T1 JOIN architect AS t2 ON T1.architect_id  =  T2.id WHERE T2.nationality  =  'American' OR T2.nationality  =  'Canadian';


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids and names of the architects who built at least 3 bridges ? [/INST]

Output: SELECT T1.id ,  T1.name FROM architect AS T1 JOIN bridge AS T2 ON T1.id  =  T2.architect_id GROUP BY T1.id HAVING count(*)  >=  3;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What is the id, name and nationality of the architect who built most mills? [/INST]

Output: SELECT T1.id ,  T1.name ,  T1.nationality FROM architect AS T1 JOIN mill AS T2 ON T1.id  =  T2.architect_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids, names and genders of the architects who built two bridges or one mill? [/INST]

Output: SELECT T1.id ,  T1.name ,  T1.gender FROM architect AS T1 JOIN bridge AS T2 ON T1.id  =  T2.architect_id GROUP BY T1.id HAVING count(*)  =  2 UNION SELECT T1.id ,  T1.name ,  T1.gender FROM architect AS T1 JOIN mill AS T2 ON T1.id  =  T2.architect_id GROUP BY T1.id HAVING count(*)  =  1;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What is the location of the bridge named 'Kolob Arch' or 'Rainbow Bridge'? [/INST]

Output: SELECT LOCATION FROM bridge WHERE name  =  'Kolob Arch' OR name  =  'Rainbow Bridge';


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: Which of the mill names contains the french word 'Moulin'? [/INST]

Output: SELECT name FROM mill WHERE name LIKE '%Moulin%';


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct name of the mills built by the architects who have also built a bridge longer than 80 meters? [/INST]

Output: SELECT DISTINCT T1.name FROM mill AS T1 JOIN architect AS t2 ON T1.architect_id  =  T2.id JOIN bridge AS T3 ON T3.architect_id  =  T2.id WHERE T3.length_meters  >  80;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: What is the most common mill type, and how many are there? [/INST]

Output: SELECT TYPE ,  count(*) FROM mill GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: How many architects haven't built a mill before year 1850? [/INST]

Output: SELECT count(*) FROM architect WHERE id NOT IN ( SELECT architect_id FROM mill WHERE built_year  <  1850 );


Input:
[INST] Here is a database schema:
architect :
id [ TEXT ] primary_key
name [ TEXT ]
nationality [ TEXT ]
gender [ TEXT ]

bridge :
architect_id [ INT ] bridge.architect_id = architect.id
id [ INT ] primary_key
name [ TEXT ]
location [ TEXT ]
length_meters [ INT ]
length_feet [ INT ]

mill :
architect_id [ INT ] mill.architect_id = architect.id
id [ INT ] primary_key
location [ TEXT ]
name [ TEXT ]
type [ TEXT ]
built_year [ INT ]
notes [ TEXT ]

Please write me a SQL statement that answers the following question: show the name of all bridges that was designed by american archtect, and sort the result by the bridge feet length. [/INST]

Output: SELECT t1.name FROM bridge AS t1 JOIN architect AS t2 ON t1.architect_id  =  t2.id WHERE t2.nationality  =  'American' ORDER BY t1.length_feet;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

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

Output: SELECT count(*) FROM book_club;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Count the number of book clubs. [/INST]

Output: SELECT count(*) FROM book_club;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: show the titles, and authors or editors for all books made after the year 1989. [/INST]

Output: SELECT book_title ,  author_or_editor FROM book_club WHERE YEAR  >  1989;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What are the titles and authors or editors that correspond to books made after 1989? [/INST]

Output: SELECT book_title ,  author_or_editor FROM book_club WHERE YEAR  >  1989;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show all distinct publishers for books. [/INST]

Output: SELECT DISTINCT publisher FROM book_club;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What are all the different book publishers? [/INST]

Output: SELECT DISTINCT publisher FROM book_club;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show the years, book titles, and publishers for all books, in descending order by year. [/INST]

Output: SELECT YEAR ,  book_title ,  publisher FROM book_club ORDER BY YEAR DESC;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What are the years, titles, and publishers for all books, ordered by year descending? [/INST]

Output: SELECT YEAR ,  book_title ,  publisher FROM book_club ORDER BY YEAR DESC;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show all publishers and the number of books for each publisher. [/INST]

Output: SELECT publisher ,  count(*) FROM book_club GROUP BY publisher;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

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

Output: SELECT publisher ,  count(*) FROM book_club GROUP BY publisher;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What is the publisher with most number of books? [/INST]

Output: SELECT publisher FROM book_club GROUP BY publisher ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Return the publisher that has published the most books. [/INST]

Output: SELECT publisher FROM book_club GROUP BY publisher ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show all book categories and the number of books in each category. [/INST]

Output: SELECT category ,  count(*) FROM book_club GROUP BY category;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: How many books fall into each category? [/INST]

Output: SELECT category ,  count(*) FROM book_club GROUP BY category;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: List categories that have at least two books after year 1989. [/INST]

Output: SELECT category FROM book_club WHERE YEAR  >  1989 GROUP BY category HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What categories have two or more corresponding books that were made after 1989? [/INST]

Output: SELECT category FROM book_club WHERE YEAR  >  1989 GROUP BY category HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show publishers with a book published in 1989 and a book in 1990. [/INST]

Output: SELECT publisher FROM book_club WHERE YEAR  =  1989 INTERSECT SELECT publisher FROM book_club WHERE YEAR  =  1990;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What are the publishers who have published a book in both 1989 and 1990? [/INST]

Output: SELECT publisher FROM book_club WHERE YEAR  =  1989 INTERSECT SELECT publisher FROM book_club WHERE YEAR  =  1990;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show all publishers which do not have a book in 1989. [/INST]

Output: SELECT publisher FROM book_club EXCEPT SELECT publisher FROM book_club WHERE YEAR  =  1989;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Which publishers did not publish a book in 1989? [/INST]

Output: SELECT publisher FROM book_club EXCEPT SELECT publisher FROM book_club WHERE YEAR  =  1989;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show all movie titles, years, and directors, ordered by budget. [/INST]

Output: SELECT title ,  YEAR ,  director FROM movie ORDER BY budget_million;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What are the titles, years, and directors of all movies, ordered by budget in millions? [/INST]

Output: SELECT title ,  YEAR ,  director FROM movie ORDER BY budget_million;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

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

Output: SELECT COUNT (DISTINCT director) FROM movie;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Count the number of different directors. [/INST]

Output: SELECT COUNT (DISTINCT director) FROM movie;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What is the title and director for the movie with highest worldwide gross in the year 2000 or before? [/INST]

Output: SELECT title ,  director FROM movie WHERE YEAR  <=  2000 ORDER BY gross_worldwide DESC LIMIT 1;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Return the title and director of the movie released in the year 2000 or earlier that had the highest worldwide gross. [/INST]

Output: SELECT title ,  director FROM movie WHERE YEAR  <=  2000 ORDER BY gross_worldwide DESC LIMIT 1;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show all director names who have a movie in both year 1999 and 2000. [/INST]

Output: SELECT director FROM movie WHERE YEAR  =  2000 INTERSECT SELECT director FROM movie WHERE YEAR  =  1999;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Which directors had a movie both in the year 1999 and 2000? [/INST]

Output: SELECT director FROM movie WHERE YEAR  =  2000 INTERSECT SELECT director FROM movie WHERE YEAR  =  1999;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show all director names who have a movie in the year 1999 or 2000. [/INST]

Output: SELECT director FROM movie WHERE YEAR  =  1999 OR YEAR  =  2000;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Which directors had a movie in either 1999 or 2000? [/INST]

Output: SELECT director FROM movie WHERE YEAR  =  1999 OR YEAR  =  2000;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What is the average, maximum, and minimum budget for all movies before 2000. [/INST]

Output: SELECT avg(budget_million) ,  max(budget_million) ,  min(budget_million) FROM movie WHERE YEAR  <  2000;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Return the average, maximum, and minimum budgets in millions for movies made before the year 2000. [/INST]

Output: SELECT avg(budget_million) ,  max(budget_million) ,  min(budget_million) FROM movie WHERE YEAR  <  2000;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: List all company names with a book published by Alyson. [/INST]

Output: SELECT T1.company_name FROM culture_company AS T1 JOIN book_club AS T2 ON T1.book_club_id  =  T2.book_club_id WHERE T2.publisher  =  'Alyson';


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What are all the company names that have a book published by Alyson? [/INST]

Output: SELECT T1.company_name FROM culture_company AS T1 JOIN book_club AS T2 ON T1.book_club_id  =  T2.book_club_id WHERE T2.publisher  =  'Alyson';


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show the movie titles and book titles for all companies in China. [/INST]

Output: SELECT T1.title ,  T3.book_title FROM movie AS T1 JOIN culture_company AS T2 ON T1.movie_id  =  T2.movie_id JOIN book_club AS T3 ON T3.book_club_id  =  T2.book_club_id WHERE T2.incorporated_in  =  'China';


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What are the titles of movies and books corresponding to companies incorporated in China? [/INST]

Output: SELECT T1.title ,  T3.book_title FROM movie AS T1 JOIN culture_company AS T2 ON T1.movie_id  =  T2.movie_id JOIN book_club AS T3 ON T3.book_club_id  =  T2.book_club_id WHERE T2.incorporated_in  =  'China';


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: Show all company names with a movie directed in year 1999. [/INST]

Output: SELECT T2.company_name FROM movie AS T1 JOIN culture_company AS T2 ON T1.movie_id  =  T2.movie_id WHERE T1.year  =  1999;


Input:
[INST] Here is a database schema:
book_club :
book_club_id [ INT ] primary_key
Year [ INT ]
Author_or_Editor [ TEXT ]
Book_Title [ TEXT ]
Publisher [ TEXT ]
Category [ TEXT ]
Result [ TEXT ]

movie :
movie_id [ INT ] primary_key
Title [ TEXT ]
Year [ INT ]
Director [ TEXT ]
Budget_million [ INT ]
Gross_worldwide [ INT ]

culture_company :
Company_name [ TEXT ] primary_key
Type [ TEXT ]
Incorporated_in [ TEXT ]
Group_Equity_Shareholding [ INT ]
book_club_id [ TEXT ] culture_company.book_club_id = book_club.book_club_id
movie_id [ TEXT ] culture_company.movie_id = movie.movie_id

Please write me a SQL statement that answers the following question: What are all company names that have a corresponding movie directed in the year 1999? [/INST]

Output: SELECT T2.company_name FROM movie AS T1 JOIN culture_company AS T2 ON T1.movie_id  =  T2.movie_id WHERE T1.year  =  1999;