Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which papers did the author "Olin Shivers" write? Give me the paper titles. [/INST]

Output: SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid WHERE t1.fname  =  "Olin" AND t1.lname  =  "Shivers";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which papers have "Stephanie Weirich" as an author? [/INST]

Output: SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid WHERE t1.fname  =  "Stephanie" AND t1.lname  =  "Weirich";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find the titles of the papers the author "Stephanie Weirich" wrote. [/INST]

Output: SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid WHERE t1.fname  =  "Stephanie" AND t1.lname  =  "Weirich";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which paper is published in an institution in "USA" and have "Turon" as its second author? [/INST]

Output: SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid JOIN inst AS t4 ON t2.instid  =  t4.instid WHERE t4.country  =  "USA" AND t2.authorder  =  2 AND t1.lname  =  "Turon";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find papers whose second author has last name "Turon" and is affiliated with an institution in the country "USA". [/INST]

Output: SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid JOIN inst AS t4 ON t2.instid  =  t4.instid WHERE t4.country  =  "USA" AND t2.authorder  =  2 AND t1.lname  =  "Turon";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find the titles of papers whose first author is affiliated with an institution in the country "Japan" and has last name "Ohori"? [/INST]

Output: SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid JOIN inst AS t4 ON t2.instid  =  t4.instid WHERE t4.country  =  "Japan" AND t2.authorder  =  1 AND t1.lname  =  "Ohori";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which papers' first author is affiliated with an institution in the country "Japan" and has last name "Ohori"? Give me the titles of the papers. [/INST]

Output: SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid JOIN inst AS t4 ON t2.instid  =  t4.instid WHERE t4.country  =  "Japan" AND t2.authorder  =  1 AND t1.lname  =  "Ohori";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: What is the last name of the author that has published the most papers? [/INST]

Output: SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid GROUP BY t1.fname ,  t1.lname ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which author has written the most papers? Find his or her last name. [/INST]

Output: SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid GROUP BY t1.fname ,  t1.lname ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

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

Output: SELECT t1.country FROM inst AS t1 JOIN authorship AS t2 ON t1.instid  =  t2.instid JOIN papers AS t3 ON t2.paperid  =  t3.paperid GROUP BY t1.country ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find the country that the most papers are affiliated with. [/INST]

Output: SELECT t1.country FROM inst AS t1 JOIN authorship AS t2 ON t1.instid  =  t2.instid JOIN papers AS t3 ON t2.paperid  =  t3.paperid GROUP BY t1.country ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find the name of the organization that has published the largest number of papers. [/INST]

Output: SELECT t1.name FROM inst AS t1 JOIN authorship AS t2 ON t1.instid  =  t2.instid JOIN papers AS t3 ON t2.paperid  =  t3.paperid GROUP BY t1.name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which institution has the most papers? Find the name of the institution. [/INST]

Output: SELECT t1.name FROM inst AS t1 JOIN authorship AS t2 ON t1.instid  =  t2.instid JOIN papers AS t3 ON t2.paperid  =  t3.paperid GROUP BY t1.name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find the titles of the papers that contain the word "ML". [/INST]

Output: SELECT title FROM papers WHERE title LIKE "%ML%";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which papers have the substring "ML" in their titles? Return the titles of the papers. [/INST]

Output: SELECT title FROM papers WHERE title LIKE "%ML%";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which paper's title contains the word "Database"? [/INST]

Output: SELECT title FROM papers WHERE title LIKE "%Database%";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which papers have the substring "Database" in their titles? Show the titles of the papers. [/INST]

Output: SELECT title FROM papers WHERE title LIKE "%Database%";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find the first names of all the authors who have written a paper with title containing the word "Functional". [/INST]

Output: SELECT t1.fname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid WHERE t3.title LIKE "%Functional%";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Who has written a paper that has the word "Functional" in its title? Return the first names of the authors. [/INST]

Output: SELECT t1.fname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid WHERE t3.title LIKE "%Functional%";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find the last names of all the authors that have written a paper with title containing the word "Monadic". [/INST]

Output: SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid WHERE t3.title LIKE "%Monadic%";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which authors have written a paper with title containing the word "Monadic"? Return their last names. [/INST]

Output: SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid  =  t2.authid JOIN papers AS t3 ON t2.paperid  =  t3.paperid WHERE t3.title LIKE "%Monadic%";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Retrieve the title of the paper that has the largest number of authors. [/INST]

Output: SELECT t2.title FROM authorship AS t1 JOIN papers AS t2 ON t1.paperid  =  t2.paperid WHERE t1.authorder  =  (SELECT max(authorder) FROM authorship);


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which paper has the most authors? Give me the paper title. [/INST]

Output: SELECT t2.title FROM authorship AS t1 JOIN papers AS t2 ON t1.paperid  =  t2.paperid WHERE t1.authorder  =  (SELECT max(authorder) FROM authorship);


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: What is the first name of the author with last name "Ueno"? [/INST]

Output: SELECT fname FROM authors WHERE lname  =  "Ueno";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which authors have last name "Ueno"? List their first names. [/INST]

Output: SELECT fname FROM authors WHERE lname  =  "Ueno";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find the last name of the author with first name "Amal". [/INST]

Output: SELECT lname FROM authors WHERE fname  =  "Amal";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Which authors have first name "Amal"? List their last names. [/INST]

Output: SELECT lname FROM authors WHERE fname  =  "Amal";


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Find the first names of all the authors ordered in alphabetical order. [/INST]

Output: SELECT fname FROM authors ORDER BY fname;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Sort the first names of all the authors in alphabetical order. [/INST]

Output: SELECT fname FROM authors ORDER BY fname;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Retrieve all the last names of authors in alphabetical order. [/INST]

Output: SELECT lname FROM authors ORDER BY lname;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Give me a list of all the last names of authors sorted in alphabetical order [/INST]

Output: SELECT lname FROM authors ORDER BY lname;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Retrieve all the first and last names of authors in the alphabetical order of last names. [/INST]

Output: SELECT fname ,  lname FROM authors ORDER BY lname;


Input:
[INST] Here is a database schema:
Inst :
instID [ INT ] primary_key
name [ TEXT ]
country [ TEXT ]

Authors :
authID [ INT ] primary_key
lname [ TEXT ]
fname [ TEXT ]

Papers :
paperID [ INT ] primary_key
title [ TEXT ]

Authorship :
authID [ INT ] primary_key Authorship.authID = Authors.authID
instID [ INT ] Authorship.instID = Inst.instID
paperID [ INT ] Authorship.paperID = Papers.paperID
authOrder [ INT ]

Please write me a SQL statement that answers the following question: Sort the list of all the first and last names of authors in alphabetical order of the last names. [/INST]

Output: SELECT fname ,  lname FROM authors ORDER BY lname;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: How many different last names do the actors and actresses have? [/INST]

Output: SELECT count(DISTINCT last_name) FROM actor;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

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

Output: SELECT count(DISTINCT last_name) FROM actor;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: What is the most popular first name of the actors? [/INST]

Output: SELECT first_name FROM actor GROUP BY first_name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Return the most common first name among all actors. [/INST]

Output: SELECT first_name FROM actor GROUP BY first_name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: What is the most popular full name of the actors? [/INST]

Output: SELECT first_name ,  last_name FROM actor GROUP BY first_name ,  last_name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Return the most common full name among all actors. [/INST]

Output: SELECT first_name ,  last_name FROM actor GROUP BY first_name ,  last_name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Which districts have at least two addresses? [/INST]

Output: SELECT district FROM address GROUP BY district HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Give the districts which have two or more addresses. [/INST]

Output: SELECT district FROM address GROUP BY district HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: What is the phone number and postal code of the address 1031 Daugavpils Parkway? [/INST]

Output: SELECT phone ,  postal_code FROM address WHERE address  =  '1031 Daugavpils Parkway';


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Give the phone and postal code corresponding to the address '1031 Daugavpils Parkway'. [/INST]

Output: SELECT phone ,  postal_code FROM address WHERE address  =  '1031 Daugavpils Parkway';


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Which city has the most addresses? List the city name, number of addresses, and city id. [/INST]

Output: SELECT T2.city ,  count(*) ,  T1.city_id FROM address AS T1 JOIN city AS T2 ON T1.city_id  =  T2.city_id GROUP BY T1.city_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: What are the city name, id, and number of addresses corresponding to the city with the most addressed? [/INST]

Output: SELECT T2.city ,  count(*) ,  T1.city_id FROM address AS T1 JOIN city AS T2 ON T1.city_id  =  T2.city_id GROUP BY T1.city_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: How many addresses are in the district of California? [/INST]

Output: SELECT count(*) FROM address WHERE district  =  'California';


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of addressed in the California district. [/INST]

Output: SELECT count(*) FROM address WHERE district  =  'California';


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Which film is rented at a fee of 0.99 and has less than 3 in the inventory? List the film title and id. [/INST]

Output: SELECT title ,  film_id FROM film WHERE rental_rate  =  0.99 INTERSECT SELECT T1.title ,  T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id  =  T2.film_id GROUP BY T1.film_id HAVING count(*)  <  3;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: What are the title and id of the film which has a rental rate of 0.99 and an inventory of below 3? [/INST]

Output: SELECT title ,  film_id FROM film WHERE rental_rate  =  0.99 INTERSECT SELECT T1.title ,  T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id  =  T2.film_id GROUP BY T1.film_id HAVING count(*)  <  3;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

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

Output: SELECT count(*) FROM city AS T1 JOIN country AS T2 ON T1.country_id  =  T2.country_id WHERE T2.country  =  'Australia';


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

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

Output: SELECT count(*) FROM city AS T1 JOIN country AS T2 ON T1.country_id  =  T2.country_id WHERE T2.country  =  'Australia';


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Which countries have at least 3 cities? [/INST]

Output: SELECT T2.country FROM city AS T1 JOIN country AS T2 ON T1.country_id  =  T2.country_id GROUP BY T2.country_id HAVING count(*)  >=  3;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: What are the countries that contain 3 or more cities? [/INST]

Output: SELECT T2.country FROM city AS T1 JOIN country AS T2 ON T1.country_id  =  T2.country_id GROUP BY T2.country_id HAVING count(*)  >=  3;


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Find all the payment dates for the payments with an amount larger than 10 and the payments handled by a staff person with the first name Elsa. [/INST]

Output: SELECT payment_date FROM payment WHERE amount  >  10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.first_name  =  'Elsa';


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: What are the payment dates for any payments that have an amount greater than 10 or were handled by a staff member with the first name Elsa? [/INST]

Output: SELECT payment_date FROM payment WHERE amount  >  10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.first_name  =  'Elsa';


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: How many customers have an active value of 1? [/INST]

Output: SELECT count(*) FROM customer WHERE active = '1';


Input:
[INST] Here is a database schema:
actor :
actor_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
last_update [ TEXT ]

address :
address_id [ INT ] primary_key
address [ TEXT ]
address2 [ TEXT ]
district [ TEXT ]
city_id [ INT ] address.city_id = city.city_id
postal_code [ TEXT ]
phone [ TEXT ]
last_update [ TEXT ]

category :
category_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

city :
city_id [ INT ] primary_key
city [ TEXT ]
country_id [ INT ] city.country_id = country.country_id
last_update [ TEXT ]

country :
country_id [ INT ] primary_key
country [ TEXT ]
last_update [ TEXT ]

customer :
customer_id [ INT ] primary_key
store_id [ INT ] customer.store_id = store.store_id
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
address_id [ INT ] customer.address_id = address.address_id
active [ TEXT ]
create_date [ TEXT ]
last_update [ TEXT ]

film :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]
release_year [ TEXT ]
language_id [ INT ] film.language_id = language.language_id
original_language_id [ INT ] film.original_language_id = language.language_id
rental_duration [ INT ]
rental_rate [ INT ]
length [ INT ]
replacement_cost [ INT ]
rating [ TEXT ]
special_features [ TEXT ]
last_update [ TEXT ]

film_actor :
actor_id [ INT ] primary_key film_actor.actor_id = actor.actor_id
film_id [ INT ] film_actor.film_id = film.film_id
last_update [ TEXT ]

film_category :
film_id [ INT ] primary_key film_category.film_id = film.film_id
category_id [ INT ] film_category.category_id = category.category_id
last_update [ TEXT ]

film_text :
film_id [ INT ] primary_key
title [ TEXT ]
description [ TEXT ]

inventory :
inventory_id [ INT ] primary_key
film_id [ INT ] inventory.film_id = film.film_id
store_id [ INT ] inventory.store_id = store.store_id
last_update [ TEXT ]

language :
language_id [ INT ] primary_key
name [ TEXT ]
last_update [ TEXT ]

payment :
payment_id [ INT ] primary_key
customer_id [ INT ] payment.customer_id = customer.customer_id
staff_id [ INT ] payment.staff_id = staff.staff_id
rental_id [ INT ] payment.rental_id = rental.rental_id
amount [ INT ]
payment_date [ TEXT ]
last_update [ TEXT ]

rental :
rental_id [ INT ] primary_key
rental_date [ TEXT ]
inventory_id [ INT ] rental.inventory_id = inventory.inventory_id
customer_id [ INT ] rental.customer_id = customer.customer_id
return_date [ TEXT ]
staff_id [ INT ] rental.staff_id = staff.staff_id
last_update [ TEXT ]

staff :
staff_id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
address_id [ INT ] staff.address_id = address.address_id
picture [ TEXT ]
email [ TEXT ]
store_id [ INT ]
active [ TEXT ]
username [ TEXT ]
password [ TEXT ]
last_update [ TEXT ]

store :
store_id [ INT ] primary_key
manager_staff_id [ INT ] store.manager_staff_id = staff.staff_id
address_id [ INT ] store.address_id = address.address_id
last_update [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of customers who are active. [/INST]

Output: SELECT count(*) FROM customer WHERE active = '1';