Question:
Find the titles of all the papers written by 'Aaron Turon'.
Additional table information: table: icfp_1

Answer: 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 = 'Aaron' AND t1.lname = 'Turon'


Question:
How many papers have 'Atsushi Ohori' published?
Additional table information: table: icfp_1

Answer: SELECT COUNT(*) 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 = 'Atsushi' AND t1.lname = 'Ohori'


Question:
How many papers are 'Atsushi Ohori' the author of?
Additional table information: table: icfp_1

Answer: SELECT COUNT(*) 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 = 'Atsushi' AND t1.lname = 'Ohori'


Question:
What is the name of the institution that 'Matthias Blume' belongs to?
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t3.name FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t1.fname = 'Matthias' AND t1.lname = 'Blume'


Question:
Which institution is the author 'Matthias Blume' belong to? Give me the name of the institution.
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t3.name FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t1.fname = 'Matthias' AND t1.lname = 'Blume'


Question:
Which institution does 'Katsuhiro Ueno' belong to?
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t3.name FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t1.fname = 'Katsuhiro' AND t1.lname = 'Ueno'


Question:
What is the name of the institution the author 'Katsuhiro Ueno' belongs to?
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t3.name FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t1.fname = 'Katsuhiro' AND t1.lname = 'Ueno'


Question:
Who belong to the institution 'University of Oxford'? Show the first names and last names.
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t1.fname, t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'University of Oxford'


Question:
Find the first names and last names of the authors whose institution affiliation is 'University of Oxford'.
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t1.fname, t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'University of Oxford'


Question:
Which authors belong to the institution 'Google'? Show the first names and last names.
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t1.fname, t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Google'


Question:
Find the first names and last names of the authors whose institution affiliation is 'Google'.
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t1.fname, t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Google'


Question:
What are the last names of the author of the paper titled 'Binders Unbound'?
Additional table information: table: icfp_1

Answer: 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 = 'Binders Unbound'


Question:
Who is the author of the paper titled 'Binders Unbound'? Give me the last name.
Additional table information: table: icfp_1

Answer: 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 = 'Binders Unbound'


Question:
Find the first and last name of the author(s) who wrote the paper 'Nameless, Painless'.
Additional table information: table: icfp_1

Answer: SELECT t1.fname, 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 = 'Nameless ,  Painless'


Question:
What are the first and last name of the author who published the paper titled 'Nameless, Painless'?
Additional table information: table: icfp_1

Answer: SELECT t1.fname, 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 = 'Nameless ,  Painless'


Question:
What are the papers published under the institution 'Indiana University'?
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t1.title FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Indiana University'


Question:
List the titles of the papers whose authors are from the institution 'Indiana University'.
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t1.title FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Indiana University'


Question:
Find all the papers published by the institution 'Google'.
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t1.title FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Google'


Question:
Which papers were written by authors from the institution 'Google'?
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t1.title FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Google'


Question:
How many papers are published by the institution 'Tokohu University'?
Additional table information: table: icfp_1

Answer: SELECT COUNT(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Tokohu University'


Question:
Find the number of papers published by authors from the institution 'Tokohu University'.
Additional table information: table: icfp_1

Answer: SELECT COUNT(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Tokohu University'


Question:
Find the number of papers published by the institution 'University of Pennsylvania'.
Additional table information: table: icfp_1

Answer: SELECT COUNT(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'University of Pennsylvania'


Question:
How many papers are written by authors from the institution 'University of Pennsylvania'?
Additional table information: table: icfp_1

Answer: SELECT COUNT(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'University of Pennsylvania'


Question:
Find the papers which have 'Olin Shivers' as an author.
Additional table information: table: icfp_1

Answer: 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'


Question:
Which papers did the author 'Olin Shivers' write? Give me the paper titles.
Additional table information: table: icfp_1

Answer: 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'


Question:
Which papers have 'Stephanie Weirich' as an author?
Additional table information: table: icfp_1

Answer: 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'


Question:
Find the titles of the papers the author 'Stephanie Weirich' wrote.
Additional table information: table: icfp_1

Answer: 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'


Question:
Which paper is published in an institution in 'USA' and have 'Turon' as its second author?
Additional table information: table: icfp_1

Answer: 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'


Question:
Find papers whose second author has last name 'Turon' and is affiliated with an institution in the country 'USA'.
Additional table information: table: icfp_1

Answer: 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'


Question:
Find the titles of papers whose first author is affiliated with an institution in the country 'Japan' and has last name 'Ohori'?
Additional table information: table: icfp_1

Answer: 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'


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.
Additional table information: table: icfp_1

Answer: 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'


Question:
What is the last name of the author that has published the most papers?
Additional table information: table: icfp_1

Answer: 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


Question:
Which author has written the most papers? Find his or her last name.
Additional table information: table: icfp_1

Answer: 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


Question:
Retrieve the country that has published the most papers.
Additional table information: table: icfp_1

Answer: 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


Question:
Find the country that the most papers are affiliated with.
Additional table information: table: icfp_1

Answer: 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


Question:
Find the name of the organization that has published the largest number of papers.
Additional table information: table: icfp_1

Answer: 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


Question:
Which institution has the most papers? Find the name of the institution.
Additional table information: table: icfp_1

Answer: 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


Question:
Find the titles of the papers that contain the word 'ML'.
Additional table information: table: icfp_1

Answer: SELECT title FROM papers WHERE title LIKE '%ML%'


Question:
Which papers have the substring 'ML' in their titles? Return the titles of the papers.
Additional table information: table: icfp_1

Answer: SELECT title FROM papers WHERE title LIKE '%ML%'


Question:
Which paper's title contains the word 'Database'?
Additional table information: table: icfp_1

Answer: SELECT title FROM papers WHERE title LIKE '%Database%'


Question:
Which papers have the substring 'Database' in their titles? Show the titles of the papers.
Additional table information: table: icfp_1

Answer: SELECT title FROM papers WHERE title LIKE '%Database%'


Question:
Find the first names of all the authors who have written a paper with title containing the word 'Functional'.
Additional table information: table: icfp_1

Answer: 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%'


Question:
Who has written a paper that has the word 'Functional' in its title? Return the first names of the authors.
Additional table information: table: icfp_1

Answer: 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%'


Question:
Find the last names of all the authors that have written a paper with title containing the word 'Monadic'.
Additional table information: table: icfp_1

Answer: 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%'


Question:
Which authors have written a paper with title containing the word 'Monadic'? Return their last names.
Additional table information: table: icfp_1

Answer: 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%'


Question:
Retrieve the title of the paper that has the largest number of authors.
Additional table information: table: icfp_1

Answer: SELECT t2.title FROM authorship AS t1 JOIN papers AS t2 ON t1.paperid = t2.paperid WHERE t1.authorder = (SELECT MAX(authorder) FROM authorship)


Question:
Which paper has the most authors? Give me the paper title.
Additional table information: table: icfp_1

Answer: SELECT t2.title FROM authorship AS t1 JOIN papers AS t2 ON t1.paperid = t2.paperid WHERE t1.authorder = (SELECT MAX(authorder) FROM authorship)


Question:
What is the first name of the author with last name 'Ueno'?
Additional table information: table: icfp_1

Answer: SELECT fname FROM authors WHERE lname = 'Ueno'


Question:
Which authors have last name 'Ueno'? List their first names.
Additional table information: table: icfp_1

Answer: SELECT fname FROM authors WHERE lname = 'Ueno'


Question:
Find the last name of the author with first name 'Amal'.
Additional table information: table: icfp_1

Answer: SELECT lname FROM authors WHERE fname = 'Amal'


Question:
Which authors have first name 'Amal'? List their last names.
Additional table information: table: icfp_1

Answer: SELECT lname FROM authors WHERE fname = 'Amal'


Question:
Find the first names of all the authors ordered in alphabetical order.
Additional table information: table: icfp_1

Answer: SELECT fname FROM authors ORDER BY fname NULLS FIRST


Question:
Sort the first names of all the authors in alphabetical order.
Additional table information: table: icfp_1

Answer: SELECT fname FROM authors ORDER BY fname NULLS FIRST


Question:
Retrieve all the last names of authors in alphabetical order.
Additional table information: table: icfp_1

Answer: SELECT lname FROM authors ORDER BY lname NULLS FIRST


Question:
Give me a list of all the last names of authors sorted in alphabetical order
Additional table information: table: icfp_1

Answer: SELECT lname FROM authors ORDER BY lname NULLS FIRST


Question:
Retrieve all the first and last names of authors in the alphabetical order of last names.
Additional table information: table: icfp_1

Answer: SELECT fname, lname FROM authors ORDER BY lname NULLS FIRST


Question:
Sort the list of all the first and last names of authors in alphabetical order of the last names.
Additional table information: table: icfp_1

Answer: SELECT fname, lname FROM authors ORDER BY lname NULLS FIRST


Question:
How many different last names do the actors and actresses have?
Additional table information: table: sakila_1

Answer: SELECT COUNT(DISTINCT last_name) FROM actor


Question:
Count the number of different last names actors have.
Additional table information: table: sakila_1

Answer: SELECT COUNT(DISTINCT last_name) FROM actor


Question:
What is the most popular first name of the actors?
Additional table information: table: sakila_1

Answer: SELECT first_name FROM actor GROUP BY first_name ORDER BY COUNT(*) DESC LIMIT 1


Question:
Return the most common first name among all actors.
Additional table information: table: sakila_1

Answer: SELECT first_name FROM actor GROUP BY first_name ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the most popular full name of the actors?
Additional table information: table: sakila_1

Answer: SELECT first_name, last_name FROM actor GROUP BY first_name, last_name ORDER BY COUNT(*) DESC LIMIT 1


Question:
Return the most common full name among all actors.
Additional table information: table: sakila_1

Answer: SELECT first_name, last_name FROM actor GROUP BY first_name, last_name ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which districts have at least two addresses?
Additional table information: table: sakila_1

Answer: SELECT district FROM address GROUP BY district HAVING COUNT(*) >= 2


Question:
Give the districts which have two or more addresses.
Additional table information: table: sakila_1

Answer: SELECT district FROM address GROUP BY district HAVING COUNT(*) >= 2


Question:
What is the phone number and postal code of the address 1031 Daugavpils Parkway?
Additional table information: table: sakila_1

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


Question:
Give the phone and postal code corresponding to the address '1031 Daugavpils Parkway'.
Additional table information: table: sakila_1

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


Question:
Which city has the most addresses? List the city name, number of addresses, and city id.
Additional table information: table: sakila_1

Answer: 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


Question:
What are the city name, id, and number of addresses corresponding to the city with the most addressed?
Additional table information: table: sakila_1

Answer: 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


Question:
How many addresses are in the district of California?
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM address WHERE district = 'California'


Question:
Count the number of addressed in the California district.
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM address WHERE district = 'California'


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.
Additional table information: table: sakila_1

Answer: 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


Question:
What are the title and id of the film which has a rental rate of 0.99 and an inventory of below 3?
Additional table information: table: sakila_1

Answer: 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


Question:
How many cities are in Australia?
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id WHERE T2.country = 'Australia'


Question:
Count the number of cities in Australia.
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id WHERE T2.country = 'Australia'


Question:
Which countries have at least 3 cities?
Additional table information: table: sakila_1

Answer: 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


Question:
What are the countries that contain 3 or more cities?
Additional table information: table: sakila_1

Answer: 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


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.
Additional table information: table: sakila_1

Answer: 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'


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?
Additional table information: table: sakila_1

Answer: 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'


Question:
How many customers have an active value of 1?
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM customer WHERE active = '1'


Question:
Count the number of customers who are active.
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM customer WHERE active = '1'


Question:
Which film has the highest rental rate? And what is the rate?
Additional table information: table: sakila_1

Answer: SELECT title, rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1


Question:
What are the title and rental rate of the film with the highest rental rate?
Additional table information: table: sakila_1

Answer: SELECT title, rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1


Question:
Which film has the most number of actors or actresses? List the film name, film id and description.
Additional table information: table: sakila_1

Answer: SELECT T2.title, T2.film_id, T2.description FROM film_actor AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.film_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the title, id, and description of the movie with the greatest number of actors?
Additional table information: table: sakila_1

Answer: SELECT T2.title, T2.film_id, T2.description FROM film_actor AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.film_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which film actor (actress) starred the most films? List his or her first name, last name and actor id.
Additional table information: table: sakila_1

Answer: SELECT T2.first_name, T2.last_name, T2.actor_id FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Return the full name and id of the actor or actress who starred in the greatest number of films.
Additional table information: table: sakila_1

Answer: SELECT T2.first_name, T2.last_name, T2.actor_id FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which film actors (actresses) played a role in more than 30 films? List his or her first name and last name.
Additional table information: table: sakila_1

Answer: SELECT T2.first_name, T2.last_name FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id HAVING COUNT(*) > 30


Question:
What are the full names of actors who had roles in more than 30 films?
Additional table information: table: sakila_1

Answer: SELECT T2.first_name, T2.last_name FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id HAVING COUNT(*) > 30


Question:
Which store owns most items?
Additional table information: table: sakila_1

Answer: SELECT store_id FROM inventory GROUP BY store_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the id of the store that has the most items in inventory?
Additional table information: table: sakila_1

Answer: SELECT store_id FROM inventory GROUP BY store_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the total amount of all payments?
Additional table information: table: sakila_1

Answer: SELECT SUM(amount) FROM payment


Question:
Return the sum of all payment amounts.
Additional table information: table: sakila_1

Answer: SELECT SUM(amount) FROM payment


Question:
Which customer, who has made at least one payment, has spent the least money? List his or her first name, last name, and the id.
Additional table information: table: sakila_1

Answer: SELECT T1.first_name, T1.last_name, T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY SUM(amount) ASC NULLS FIRST LIMIT 1


Question:
What is the full name and id of the customer who has the lowest total amount of payment?
Additional table information: table: sakila_1

Answer: SELECT T1.first_name, T1.last_name, T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY SUM(amount) ASC NULLS FIRST LIMIT 1


Question:
What is the genre name of the film HUNGER ROOF?
Additional table information: table: sakila_1

Answer: SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id = T2.category_id JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.title = 'HUNGER ROOF'


Question:
Return the name of the category to which the film 'HUNGER ROOF' belongs.
Additional table information: table: sakila_1

Answer: SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id = T2.category_id JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.title = 'HUNGER ROOF'


Question:
How many films are there in each category? List the genre name, genre id and the count.
Additional table information: table: sakila_1

Answer: SELECT T2.name, T1.category_id, COUNT(*) FROM film_category AS T1 JOIN category AS T2 ON T1.category_id = T2.category_id GROUP BY T1.category_id


Question:
What are the names and ids of the different categories, and how many films are in each?
Additional table information: table: sakila_1

Answer: SELECT T2.name, T1.category_id, COUNT(*) FROM film_category AS T1 JOIN category AS T2 ON T1.category_id = T2.category_id GROUP BY T1.category_id


Question:
Which film has the most copies in the inventory? List both title and id.
Additional table information: table: sakila_1

Answer: 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 ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the title and id of the film that has the greatest number of copies in inventory?
Additional table information: table: sakila_1

Answer: 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 ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the film title and inventory id of the item in the inventory which was rented most frequently?
Additional table information: table: sakila_1

Answer: SELECT T1.title, T2.inventory_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id GROUP BY T2.inventory_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Return the title and inventory id of the film that is rented most often.
Additional table information: table: sakila_1

Answer: SELECT T1.title, T2.inventory_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id GROUP BY T2.inventory_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
How many languages are in these films?
Additional table information: table: sakila_1

Answer: SELECT COUNT(DISTINCT language_id) FROM film


Question:
Count the number of different languages in these films.
Additional table information: table: sakila_1

Answer: SELECT COUNT(DISTINCT language_id) FROM film


Question:
What are all the movies rated as R? List the titles.
Additional table information: table: sakila_1

Answer: SELECT title FROM film WHERE rating = 'R'


Question:
Return the titles of any movies with an R rating.
Additional table information: table: sakila_1

Answer: SELECT title FROM film WHERE rating = 'R'


Question:
Where is store 1 located?
Additional table information: table: sakila_1

Answer: SELECT T2.address FROM store AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE store_id = 1


Question:
Return the address of store 1.
Additional table information: table: sakila_1

Answer: SELECT T2.address FROM store AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE store_id = 1


Question:
Which staff handled least number of payments? List the full name and the id.
Additional table information: table: sakila_1

Answer: SELECT T1.first_name, T1.last_name, T1.staff_id FROM staff AS T1 JOIN payment AS T2 ON T1.staff_id = T2.staff_id GROUP BY T1.staff_id ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
Give the full name and staff id of the staff who has handled the fewest payments.
Additional table information: table: sakila_1

Answer: SELECT T1.first_name, T1.last_name, T1.staff_id FROM staff AS T1 JOIN payment AS T2 ON T1.staff_id = T2.staff_id GROUP BY T1.staff_id ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
Which language does the film AIRPORT POLLOCK use? List the language name.
Additional table information: table: sakila_1

Answer: SELECT T2.name FROM film AS T1 JOIN LANGUAGE AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'AIRPORT POLLOCK'


Question:
What is the name of the language that the film 'AIRPORT POLLOCK' is in?
Additional table information: table: sakila_1

Answer: SELECT T2.name FROM film AS T1 JOIN LANGUAGE AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'AIRPORT POLLOCK'


Question:
How many stores are there?
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM store


Question:
Count the number of stores.
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM store


Question:
How many kinds of different ratings are listed?
Additional table information: table: sakila_1

Answer: SELECT COUNT(DISTINCT rating) FROM film


Question:
Count the number of different film ratings.
Additional table information: table: sakila_1

Answer: SELECT COUNT(DISTINCT rating) FROM film


Question:
Which movies have 'Deleted Scenes' as a substring in the special feature?
Additional table information: table: sakila_1

Answer: SELECT title FROM film WHERE special_features LIKE '%Deleted Scenes%'


Question:
Return the titles of films that include 'Deleted Scenes' in their special feature section.
Additional table information: table: sakila_1

Answer: SELECT title FROM film WHERE special_features LIKE '%Deleted Scenes%'


Question:
How many items in inventory does store 1 have?
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM inventory WHERE store_id = 1


Question:
Count the number of items store 1 has in stock.
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM inventory WHERE store_id = 1


Question:
When did the first payment happen?
Additional table information: table: sakila_1

Answer: SELECT payment_date FROM payment ORDER BY payment_date ASC NULLS FIRST LIMIT 1


Question:
What was the date of the earliest payment?
Additional table information: table: sakila_1

Answer: SELECT payment_date FROM payment ORDER BY payment_date ASC NULLS FIRST LIMIT 1


Question:
Where does the customer with the first name Linda live? And what is her email?
Additional table information: table: sakila_1

Answer: SELECT T2.address, T1.email FROM customer AS T1 JOIN address AS T2 ON T2.address_id = T1.address_id WHERE T1.first_name = 'LINDA'


Question:
Return the address and email of the customer with the first name Linda.
Additional table information: table: sakila_1

Answer: SELECT T2.address, T1.email FROM customer AS T1 JOIN address AS T2 ON T2.address_id = T1.address_id WHERE T1.first_name = 'LINDA'


Question:
Find all the films longer than 100 minutes, or rated PG, except those who cost more than 200 for replacement. List the titles.
Additional table information: table: sakila_1

Answer: SELECT title FROM film WHERE LENGTH > 100 OR rating = 'PG' EXCEPT SELECT title FROM film WHERE replacement_cost > 200


Question:
What are the titles of films that are either longer than 100 minutes or rated PG other than those that cost more than 200 to replace?
Additional table information: table: sakila_1

Answer: SELECT title FROM film WHERE LENGTH > 100 OR rating = 'PG' EXCEPT SELECT title FROM film WHERE replacement_cost > 200


Question:
What is the first name and the last name of the customer who made the earliest rental?
Additional table information: table: sakila_1

Answer: SELECT T1.first_name, T1.last_name FROM customer AS T1 JOIN rental AS T2 ON T1.customer_id = T2.customer_id ORDER BY T2.rental_date ASC NULLS FIRST LIMIT 1


Question:
Return the full name of the customer who made the first rental.
Additional table information: table: sakila_1

Answer: SELECT T1.first_name, T1.last_name FROM customer AS T1 JOIN rental AS T2 ON T1.customer_id = T2.customer_id ORDER BY T2.rental_date ASC NULLS FIRST LIMIT 1


Question:
What is the full name of the staff member who has rented a film to a customer with the first name April and the last name Burns?
Additional table information: table: sakila_1

Answer: SELECT DISTINCT T1.first_name, T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id = T2.staff_id JOIN customer AS T3 ON T2.customer_id = T3.customer_id WHERE T3.first_name = 'APRIL' AND T3.last_name = 'BURNS'


Question:
Return the full name of the staff who provided a customer with the first name April and the last name Burns with a film rental.
Additional table information: table: sakila_1

Answer: SELECT DISTINCT T1.first_name, T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id = T2.staff_id JOIN customer AS T3 ON T2.customer_id = T3.customer_id WHERE T3.first_name = 'APRIL' AND T3.last_name = 'BURNS'


Question:
Which store has most the customers?
Additional table information: table: sakila_1

Answer: SELECT store_id FROM customer GROUP BY store_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Return the id of the store with the most customers.
Additional table information: table: sakila_1

Answer: SELECT store_id FROM customer GROUP BY store_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the largest payment amount?
Additional table information: table: sakila_1

Answer: SELECT amount FROM payment ORDER BY amount DESC LIMIT 1


Question:
Return the amount of the largest payment.
Additional table information: table: sakila_1

Answer: SELECT amount FROM payment ORDER BY amount DESC LIMIT 1


Question:
Where does the staff member with the first name Elsa live?
Additional table information: table: sakila_1

Answer: SELECT T2.address FROM staff AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE T1.first_name = 'Elsa'


Question:
Give the address of the staff member who has the first name Elsa.
Additional table information: table: sakila_1

Answer: SELECT T2.address FROM staff AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE T1.first_name = 'Elsa'


Question:
What are the first names of customers who have not rented any films after '2005-08-23 02:06:01'?
Additional table information: table: sakila_1

Answer: SELECT first_name FROM customer WHERE NOT customer_id IN (SELECT customer_id FROM rental WHERE rental_date > '2005-08-23 02:06:01')


Question:
Return the first names of customers who did not rented a film after the date '2005-08-23 02:06:01'.
Additional table information: table: sakila_1

Answer: SELECT first_name FROM customer WHERE NOT customer_id IN (SELECT customer_id FROM rental WHERE rental_date > '2005-08-23 02:06:01')


Question:
How many bank branches are there?
Additional table information: table: loan_1

Answer: SELECT COUNT(*) FROM bank


Question:
Count the number of bank branches.
Additional table information: table: loan_1

Answer: SELECT COUNT(*) FROM bank


Question:
How many customers are there?
Additional table information: table: loan_1

Answer: SELECT SUM(no_of_customers) FROM bank


Question:
What is the total number of customers across banks?
Additional table information: table: loan_1

Answer: SELECT SUM(no_of_customers) FROM bank


Question:
Find the number of customers in the banks at New York City.
Additional table information: table: loan_1

Answer: SELECT SUM(no_of_customers) FROM bank WHERE city = 'New York City'


Question:
What is the total number of customers who use banks in New York City?
Additional table information: table: loan_1

Answer: SELECT SUM(no_of_customers) FROM bank WHERE city = 'New York City'


Question:
Find the average number of customers in all banks of Utah state.
Additional table information: table: loan_1

Answer: SELECT AVG(no_of_customers) FROM bank WHERE state = 'Utah'


Question:
What is the average number of customers across banks in the state of Utah?
Additional table information: table: loan_1

Answer: SELECT AVG(no_of_customers) FROM bank WHERE state = 'Utah'


Question:
Find the average number of customers cross all banks.
Additional table information: table: loan_1

Answer: SELECT AVG(no_of_customers) FROM bank


Question:
What is the average number of bank customers?
Additional table information: table: loan_1

Answer: SELECT AVG(no_of_customers) FROM bank


Question:
Find the city and state of the bank branch named morningside.
Additional table information: table: loan_1

Answer: SELECT city, state FROM bank WHERE bname = 'morningside'


Question:
What city and state is the bank with the name morningside in?
Additional table information: table: loan_1

Answer: SELECT city, state FROM bank WHERE bname = 'morningside'


Question:
Find the branch names of banks in the New York state.
Additional table information: table: loan_1

Answer: SELECT bname FROM bank WHERE state = 'New York'


Question:
What are the names of banks in the state of New York?
Additional table information: table: loan_1

Answer: SELECT bname FROM bank WHERE state = 'New York'


Question:
List the name of all customers sorted by their account balance in ascending order.
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer ORDER BY acc_bal NULLS FIRST


Question:
What are the names of all customers, ordered by account balance?
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer ORDER BY acc_bal NULLS FIRST


Question:
List the name of all different customers who have some loan sorted by their total loan amount.
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY SUM(T2.amount) NULLS FIRST


Question:
What are the names of the different customers who have taken out a loan, ordered by the total amount that they have taken?
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY SUM(T2.amount) NULLS FIRST


Question:
Find the state, account type, and credit score of the customer whose number of loan is 0.
Additional table information: table: loan_1

Answer: SELECT state, acc_type, credit_score FROM customer WHERE no_of_loans = 0


Question:
What are the states, account types, and credit scores for customers who have 0 loans?
Additional table information: table: loan_1

Answer: SELECT state, acc_type, credit_score FROM customer WHERE no_of_loans = 0


Question:
Find the number of different cities which banks are located at.
Additional table information: table: loan_1

Answer: SELECT COUNT(DISTINCT city) FROM bank


Question:
In how many different cities are banks located?
Additional table information: table: loan_1

Answer: SELECT COUNT(DISTINCT city) FROM bank


Question:
Find the number of different states which banks are located at.
Additional table information: table: loan_1

Answer: SELECT COUNT(DISTINCT state) FROM bank


Question:
In how many different states are banks located?
Additional table information: table: loan_1

Answer: SELECT COUNT(DISTINCT state) FROM bank


Question:
How many distinct types of accounts are there?
Additional table information: table: loan_1

Answer: SELECT COUNT(DISTINCT acc_type) FROM customer


Question:
Count the number of different account types.
Additional table information: table: loan_1

Answer: SELECT COUNT(DISTINCT acc_type) FROM customer


Question:
Find the name and account balance of the customer whose name includes the letter ‘a’.
Additional table information: table: loan_1

Answer: SELECT cust_name, acc_bal FROM customer WHERE cust_name LIKE '%a%'


Question:
What are the names and account balances of customers with the letter a in their names?
Additional table information: table: loan_1

Answer: SELECT cust_name, acc_bal FROM customer WHERE cust_name LIKE '%a%'


Question:
Find the total account balance of each customer from Utah or Texas.
Additional table information: table: loan_1

Answer: SELECT SUM(acc_bal) FROM customer WHERE state = 'Utah' OR state = 'Texas'


Question:
What are the total account balances for each customer from Utah or Texas?
Additional table information: table: loan_1

Answer: SELECT SUM(acc_bal) FROM customer WHERE state = 'Utah' OR state = 'Texas'


Question:
Find the name of customers who have both saving and checking account types.
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking'


Question:
What are the names of customers who have both savings and checking accounts?
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking'


Question:
Find the name of customers who do not have an saving account.
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'


Question:
What are the names of customers who do not have saving accounts?
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'


Question:
Find the name of customers who do not have a loan with a type of Mortgages.
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer EXCEPT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE T2.loan_type = 'Mortgages'


Question:
What are the names of customers who have not taken a Mortage loan?
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer EXCEPT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE T2.loan_type = 'Mortgages'


Question:
Find the name of customers who have loans of both Mortgages and Auto.
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Mortgages' INTERSECT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Auto'


Question:
What are the names of customers who have taken both Mortgage and Auto loans?
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Mortgages' INTERSECT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Auto'


Question:
Find the name of customers whose credit score is below the average credit scores of all customers.
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer WHERE credit_score < (SELECT AVG(credit_score) FROM customer)


Question:
What are the names of customers with credit score less than the average credit score across customers?
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer WHERE credit_score < (SELECT AVG(credit_score) FROM customer)


Question:
Find the branch name of the bank that has the most number of customers.
Additional table information: table: loan_1

Answer: SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1


Question:
What is the name of the bank branch with the greatest number of customers?
Additional table information: table: loan_1

Answer: SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1


Question:
Find the name of customer who has the lowest credit score.
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer ORDER BY credit_score NULLS FIRST LIMIT 1


Question:
What is the name of the customer with the worst credit score?
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer ORDER BY credit_score NULLS FIRST LIMIT 1


Question:
Find the name, account type, and account balance of the customer who has the highest credit score.
Additional table information: table: loan_1

Answer: SELECT cust_name, acc_type, acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1


Question:
What is the name, account type, and account balance corresponding to the customer with the highest credit score?
Additional table information: table: loan_1

Answer: SELECT cust_name, acc_type, acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1


Question:
Find the name of customer who has the highest amount of loans.
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY SUM(T2.amount) DESC LIMIT 1


Question:
What is the name of the customer who has greatest total loan amount?
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY SUM(T2.amount) DESC LIMIT 1


Question:
Find the state which has the most number of customers.
Additional table information: table: loan_1

Answer: SELECT state FROM bank GROUP BY state ORDER BY SUM(no_of_customers) DESC LIMIT 1


Question:
Which state has the greatest total number of bank customers?
Additional table information: table: loan_1

Answer: SELECT state FROM bank GROUP BY state ORDER BY SUM(no_of_customers) DESC LIMIT 1


Question:
For each account type, find the average account balance of customers with credit score lower than 50.
Additional table information: table: loan_1

Answer: SELECT AVG(acc_bal), acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type


Question:
What is the average account balance of customers with credit score below 50 for the different account types?
Additional table information: table: loan_1

Answer: SELECT AVG(acc_bal), acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type


Question:
For each state, find the total account balance of customers whose credit score is above 100.
Additional table information: table: loan_1

Answer: SELECT SUM(acc_bal), state FROM customer WHERE credit_score > 100 GROUP BY state


Question:
What is the total account balance for customers with a credit score of above 100 for the different states?
Additional table information: table: loan_1

Answer: SELECT SUM(acc_bal), state FROM customer WHERE credit_score > 100 GROUP BY state


Question:
Find the total amount of loans offered by each bank branch.
Additional table information: table: loan_1

Answer: SELECT SUM(amount), T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname


Question:
What are the names of the different bank branches, and what are their total loan amounts?
Additional table information: table: loan_1

Answer: SELECT SUM(amount), T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname


Question:
Find the name of customers who have more than one loan.
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING COUNT(*) > 1


Question:
What are the names of customers who have taken out more than one loan?
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING COUNT(*) > 1


Question:
Find the name and account balance of the customers who have loans with a total amount of more than 5000.
Additional table information: table: loan_1

Answer: SELECT T1.cust_name, T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING SUM(T2.amount) > 5000


Question:
What are the names and account balances for customers who have taken a total amount of more than 5000 in loans?
Additional table information: table: loan_1

Answer: SELECT T1.cust_name, T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING SUM(T2.amount) > 5000


Question:
Find the name of bank branch that provided the greatest total amount of loans.
Additional table information: table: loan_1

Answer: SELECT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname ORDER BY SUM(T2.amount) DESC LIMIT 1


Question:
What is the name of the bank branch that has lent the greatest amount?
Additional table information: table: loan_1

Answer: SELECT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname ORDER BY SUM(T2.amount) DESC LIMIT 1


Question:
Find the name of bank branch that provided the greatest total amount of loans to customers with credit score is less than 100.
Additional table information: table: loan_1

Answer: SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100 GROUP BY T2.bname ORDER BY SUM(T1.amount) DESC LIMIT 1


Question:
What is the name of the bank branch that has lended the largest total amount in loans, specifically to customers with credit scores below 100?
Additional table information: table: loan_1

Answer: SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100 GROUP BY T2.bname ORDER BY SUM(T1.amount) DESC LIMIT 1


Question:
Find the name of bank branches that provided some loans.
Additional table information: table: loan_1

Answer: SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id


Question:
What are the names of the different banks that have provided loans?
Additional table information: table: loan_1

Answer: SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id


Question:
Find the name and credit score of the customers who have some loans.
Additional table information: table: loan_1

Answer: SELECT DISTINCT T1.cust_name, T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id


Question:
What are the different names and credit scores of customers who have taken a loan?
Additional table information: table: loan_1

Answer: SELECT DISTINCT T1.cust_name, T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id


Question:
Find the the name of the customers who have a loan with amount more than 3000.
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE amount > 3000


Question:
What are the names of customers who have a loan of more than 3000 in amount?
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE amount > 3000


Question:
Find the city and name of bank branches that provide business loans.
Additional table information: table: loan_1

Answer: SELECT T1.bname, T1.city FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T2.loan_type = 'Business'


Question:
What are the names and cities of bank branches that offer loans for business?
Additional table information: table: loan_1

Answer: SELECT T1.bname, T1.city FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T2.loan_type = 'Business'


Question:
Find the names of bank branches that have provided a loan to any customer whose credit score is below 100.
Additional table information: table: loan_1

Answer: SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100


Question:
What are the names of banks that have loaned money to customers with credit scores below 100?
Additional table information: table: loan_1

Answer: SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100


Question:
Find the total amount of loans provided by bank branches in the state of New York.
Additional table information: table: loan_1

Answer: SELECT SUM(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T1.state = 'New York'


Question:
What is the total amount of money loaned by banks in New York state?
Additional table information: table: loan_1

Answer: SELECT SUM(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T1.state = 'New York'


Question:
Find the average credit score of the customers who have some loan.
Additional table information: table: loan_1

Answer: SELECT AVG(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan)


Question:
What is the average credit score for customers who have taken a loan?
Additional table information: table: loan_1

Answer: SELECT AVG(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan)


Question:
Find the average credit score of the customers who do not have any loan.
Additional table information: table: loan_1

Answer: SELECT AVG(credit_score) FROM customer WHERE NOT cust_id IN (SELECT cust_id FROM loan)


Question:
What is the average credit score for customers who have never taken a loan?
Additional table information: table: loan_1

Answer: SELECT AVG(credit_score) FROM customer WHERE NOT cust_id IN (SELECT cust_id FROM loan)


Question:
How many assessment notes are there in total?
Additional table information: table: behavior_monitoring

Answer: SELECT COUNT(*) FROM ASSESSMENT_NOTES


Question:
What are the dates of the assessment notes?
Additional table information: table: behavior_monitoring

Answer: SELECT date_of_notes FROM Assessment_Notes


Question:
How many addresses have zip code 197?
Additional table information: table: behavior_monitoring

Answer: SELECT COUNT(*) FROM ADDRESSES WHERE zip_postcode = '197'


Question:
How many distinct incident type codes are there?
Additional table information: table: behavior_monitoring

Answer: SELECT COUNT(DISTINCT incident_type_code) FROM Behavior_Incident


Question:
Return all distinct detention type codes.
Additional table information: table: behavior_monitoring

Answer: SELECT DISTINCT detention_type_code FROM Detention


Question:
What are the start and end dates for incidents with incident type code 'NOISE'?
Additional table information: table: behavior_monitoring

Answer: SELECT date_incident_start, date_incident_end FROM Behavior_Incident WHERE incident_type_code = 'NOISE'


Question:
Return all detention summaries.
Additional table information: table: behavior_monitoring

Answer: SELECT detention_summary FROM Detention


Question:
Return the cell phone number and email address for all students.
Additional table information: table: behavior_monitoring

Answer: SELECT cell_mobile_number, email_address FROM STUDENTS


Question:
What is the email of the student with first name 'Emma' and last name 'Rohan'?
Additional table information: table: behavior_monitoring

Answer: SELECT email_address FROM Students WHERE first_name = 'Emma' AND last_name = 'Rohan'


Question:
How many distinct students have been in detention?
Additional table information: table: behavior_monitoring

Answer: SELECT COUNT(DISTINCT student_id) FROM Students_in_Detention


Question:
What is the gender of the teacher with last name 'Medhurst'?
Additional table information: table: behavior_monitoring

Answer: SELECT gender FROM TEACHERS WHERE last_name = 'Medhurst'


Question:
What is the incident type description for the incident type with code 'VIOLENCE'?
Additional table information: table: behavior_monitoring

Answer: SELECT incident_type_description FROM Ref_Incident_Type WHERE incident_type_code = 'VIOLENCE'


Question:
Find the maximum and minimum monthly rental for all student addresses.
Additional table information: table: behavior_monitoring

Answer: SELECT MAX(monthly_rental), MIN(monthly_rental) FROM Student_Addresses


Question:
Find the first names of teachers whose email address contains the word 'man'.
Additional table information: table: behavior_monitoring

Answer: SELECT first_name FROM Teachers WHERE email_address LIKE '%man%'


Question:
List all information about the assessment notes sorted by date in ascending order.
Additional table information: table: behavior_monitoring

Answer: SELECT * FROM Assessment_Notes ORDER BY date_of_notes ASC NULLS FIRST


Question:
List all cities of addresses in alphabetical order.
Additional table information: table: behavior_monitoring

Answer: SELECT city FROM Addresses ORDER BY city NULLS FIRST


Question:
Find the first names and last names of teachers in alphabetical order of last name.
Additional table information: table: behavior_monitoring

Answer: SELECT first_name, last_name FROM Teachers ORDER BY last_name NULLS FIRST


Question:
Find all information about student addresses, and sort by monthly rental in descending order.
Additional table information: table: behavior_monitoring

Answer: SELECT * FROM Student_Addresses ORDER BY monthly_rental DESC


Question:
Find the id and first name of the student that has the most number of assessment notes?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.student_id, T2.first_name FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the ids and first names of the 3 teachers that have the most number of assessment notes?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.teacher_id, T2.first_name FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id GROUP BY T1.teacher_id ORDER BY COUNT(*) DESC LIMIT 3


Question:
Find the id and last name of the student that has the most behavior incidents?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.student_id, T2.last_name FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the id and last name of the teacher that has the most detentions with detention type code 'AFTER'?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.teacher_id, T2.last_name FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T1.detention_type_code = 'AFTER' GROUP BY T1.teacher_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the id and first name of the student whose addresses have the highest average monthly rental?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.student_id, T2.first_name FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY AVG(monthly_rental) DESC LIMIT 1


Question:
Find the id and city of the student address with the highest average monthly rental.
Additional table information: table: behavior_monitoring

Answer: SELECT T2.address_id, T1.city FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id ORDER BY AVG(monthly_rental) DESC LIMIT 1


Question:
What are the code and description of the most frequent behavior incident type?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.incident_type_code, T2.incident_type_description FROM Behavior_Incident AS T1 JOIN Ref_Incident_Type AS T2 ON T1.incident_type_code = T2.incident_type_code GROUP BY T1.incident_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the code and description of the least frequent detention type ?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.detention_type_code, T2.detention_type_description FROM Detention AS T1 JOIN Ref_Detention_Type AS T2 ON T1.detention_type_code = T2.detention_type_code GROUP BY T1.detention_type_code ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
Find the dates of assessment notes for students with first name 'Fanny'.
Additional table information: table: behavior_monitoring

Answer: SELECT T1.date_of_notes FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.first_name = 'Fanny'


Question:
Find the texts of assessment notes for teachers with last name 'Schuster'.
Additional table information: table: behavior_monitoring

Answer: SELECT T1.text_of_notes FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = 'Schuster'


Question:
Find the start and end dates of behavior incidents of students with last name 'Fahey'.
Additional table information: table: behavior_monitoring

Answer: SELECT T1.date_incident_start, date_incident_end FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.last_name = 'Fahey'


Question:
Find the start and end dates of detentions of teachers with last name 'Schultz'.
Additional table information: table: behavior_monitoring

Answer: SELECT T1.datetime_detention_start, datetime_detention_end FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = 'Schultz'


Question:
What are the id and zip code of the address with the highest monthly rental?
Additional table information: table: behavior_monitoring

Answer: SELECT T2.address_id, T1.zip_postcode FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id ORDER BY monthly_rental DESC LIMIT 1


Question:
What is the cell phone number of the student whose address has the lowest monthly rental?
Additional table information: table: behavior_monitoring

Answer: SELECT T2.cell_mobile_number FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id ORDER BY T1.monthly_rental ASC NULLS FIRST LIMIT 1


Question:
What are the monthly rentals of student addresses in Texas state?
Additional table information: table: behavior_monitoring

Answer: SELECT T2.monthly_rental FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = 'Texas'


Question:
What are the first names and last names of students with address in Wisconsin state?
Additional table information: table: behavior_monitoring

Answer: SELECT T2.first_name, T2.last_name FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = 'Wisconsin'


Question:
What are the line 1 and average monthly rentals of all student addresses?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.line_1, AVG(T2.monthly_rental) FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id


Question:
What is the zip code of the address where the teacher with first name 'Lyla' lives?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T2.first_name = 'Lyla'


Question:
What are the email addresses of teachers whose address has zip code '918'?
Additional table information: table: behavior_monitoring

Answer: SELECT T2.email_address FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T1.zip_postcode = '918'


Question:
How many students are not involved in any behavior incident?
Additional table information: table: behavior_monitoring

Answer: SELECT COUNT(*) FROM STUDENTS WHERE NOT student_id IN (SELECT student_id FROM Behavior_Incident)


Question:
Find the last names of teachers who are not involved in any detention.
Additional table information: table: behavior_monitoring

Answer: SELECT last_name FROM Teachers EXCEPT SELECT T1.last_name FROM Teachers AS T1 JOIN Detention AS T2 ON T1.teacher_id = T2.teacher_id


Question:
What are the line 1 of addresses shared by some students and some teachers?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.line_1 FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.address_id INTERSECT SELECT T1.line_1 FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id


Question:
Which assets have 2 parts and have less than 2 fault logs? List the asset id and detail.
Additional table information: table: assets_maintenance

Answer: SELECT T1.asset_id, T1.asset_details FROM Assets AS T1 JOIN Asset_Parts AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING COUNT(*) = 2 INTERSECT SELECT T1.asset_id, T1.asset_details FROM Assets AS T1 JOIN Fault_Log AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING COUNT(*) < 2


Question:
How many assets does each maintenance contract contain? List the number and the contract id.
Additional table information: table: assets_maintenance

Answer: SELECT COUNT(*), T1.maintenance_contract_id FROM Maintenance_Contracts AS T1 JOIN Assets AS T2 ON T1.maintenance_contract_id = T2.maintenance_contract_id GROUP BY T1.maintenance_contract_id


Question:
How many assets does each third party company supply? List the count and the company id.
Additional table information: table: assets_maintenance

Answer: SELECT COUNT(*), T1.company_id FROM Third_Party_Companies AS T1 JOIN Assets AS T2 ON T1.company_id = T2.supplier_company_id GROUP BY T1.company_id


Question:
Which third party companies have at least 2 maintenance engineers or have at least 2 maintenance contracts? List the company id and name.
Additional table information: table: assets_maintenance

Answer: SELECT T1.company_id, T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Engineers AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id HAVING COUNT(*) >= 2 UNION SELECT T3.company_id, T3.company_name FROM Third_Party_Companies AS T3 JOIN Maintenance_Contracts AS T4 ON T3.company_id = T4.maintenance_contract_company_id GROUP BY T3.company_id HAVING COUNT(*) >= 2


Question:
What is the name and id of the staff who recorded the fault log but has not contacted any visiting engineers?
Additional table information: table: assets_maintenance

Answer: SELECT T1.staff_name, T1.staff_id FROM Staff AS T1 JOIN Fault_Log AS T2 ON T1.staff_id = T2.recorded_by_staff_id EXCEPT SELECT T3.staff_name, T3.staff_id FROM Staff AS T3 JOIN Engineer_Visits AS T4 ON T3.staff_id = T4.contact_staff_id


Question:
Which engineer has visited the most times? Show the engineer id, first name and last name.
Additional table information: table: assets_maintenance

Answer: SELECT T1.engineer_id, T1.first_name, T1.last_name FROM Maintenance_Engineers AS T1, Engineer_Visits AS T2 GROUP BY T1.engineer_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which parts have more than 2 faults? Show the part name and id.
Additional table information: table: assets_maintenance

Answer: SELECT T1.part_name, T1.part_id FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_id HAVING COUNT(*) > 2


Question:
List all every engineer's first name, last name, details and coresponding skill description.
Additional table information: table: assets_maintenance

Answer: SELECT T1.first_name, T1.last_name, T1.other_details, T3.skill_description FROM Maintenance_Engineers AS T1 JOIN Engineer_Skills AS T2 ON T1.engineer_id = T2.engineer_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id


Question:
For all the faults of different parts, what are all the decriptions of the skills required to fix them? List the name of the faults and the skill description.
Additional table information: table: assets_maintenance

Answer: SELECT T1.fault_short_name, T3.skill_description FROM Part_Faults AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.part_fault_id = T2.part_fault_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id


Question:
How many assets can each parts be used in? List the part name and the number.
Additional table information: table: assets_maintenance

Answer: SELECT T1.part_name, COUNT(*) FROM Parts AS T1 JOIN Asset_Parts AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name


Question:
What are all the fault descriptions and the fault status of all the faults recoreded in the logs?
Additional table information: table: assets_maintenance

Answer: SELECT T1.fault_description, T2.fault_status FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id


Question:
How many engineer visits are required at most for a single fault log? List the number and the log entry id.
Additional table information: table: assets_maintenance

Answer: SELECT COUNT(*), T1.fault_log_entry_id FROM Fault_Log AS T1 JOIN Engineer_Visits AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY T1.fault_log_entry_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are all the distinct last names of all the engineers?
Additional table information: table: assets_maintenance

Answer: SELECT DISTINCT last_name FROM Maintenance_Engineers


Question:
How many fault status codes are recorded in the fault log parts table?
Additional table information: table: assets_maintenance

Answer: SELECT DISTINCT fault_status FROM Fault_Log_Parts


Question:
Which engineers have never visited to maintain the assets? List the engineer first name and last name.
Additional table information: table: assets_maintenance

Answer: SELECT first_name, last_name FROM Maintenance_Engineers WHERE NOT engineer_id IN (SELECT engineer_id FROM Engineer_Visits)


Question:
List the asset id, details, make and model for every asset.
Additional table information: table: assets_maintenance

Answer: SELECT asset_id, asset_details, asset_make, asset_model FROM Assets


Question:
When was the first asset acquired?
Additional table information: table: assets_maintenance

Answer: SELECT asset_acquired_date FROM Assets ORDER BY asset_acquired_date ASC NULLS FIRST LIMIT 1


Question:
Which part fault requires the most number of skills to fix? List part id and name.
Additional table information: table: assets_maintenance

Answer: SELECT T1.part_id, T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id JOIN Skills_Required_To_Fix AS T3 ON T2.part_fault_id = T3.part_fault_id GROUP BY T1.part_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which kind of part has the least number of faults? List the part name.
Additional table information: table: assets_maintenance

Answer: SELECT T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
Among those engineers who have visited, which engineer makes the least number of visits? List the engineer id, first name and last name.
Additional table information: table: assets_maintenance

Answer: SELECT T1.engineer_id, T1.first_name, T1.last_name FROM Maintenance_Engineers AS T1 JOIN Engineer_Visits AS T2 ON T1.engineer_id = T2.engineer_id GROUP BY T1.engineer_id ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
Which staff have contacted which engineers? List the staff name and the engineer first name and last name.
Additional table information: table: assets_maintenance

Answer: SELECT T1.staff_name, T3.first_name, T3.last_name FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id JOIN Maintenance_Engineers AS T3 ON T2.engineer_id = T3.engineer_id


Question:
Which fault log included the most number of faulty parts? List the fault log id, description and record time.
Additional table information: table: assets_maintenance

Answer: SELECT T1.fault_log_entry_id, T1.fault_description, T1.fault_log_entry_datetime FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY T1.fault_log_entry_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which skill is used in fixing the most number of faults? List the skill id and description.
Additional table information: table: assets_maintenance

Answer: SELECT T1.skill_id, T1.skill_description FROM Skills AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.skill_id = T2.skill_id GROUP BY T1.skill_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are all the distinct asset models?
Additional table information: table: assets_maintenance

Answer: SELECT DISTINCT asset_model FROM Assets


Question:
List the all the assets make, model, details by the disposed date ascendingly.
Additional table information: table: assets_maintenance

Answer: SELECT asset_make, asset_model, asset_details FROM Assets ORDER BY asset_disposed_date ASC NULLS FIRST


Question:
Which part has the least chargeable amount? List the part id and amount.
Additional table information: table: assets_maintenance

Answer: SELECT part_id, chargeable_amount FROM Parts ORDER BY chargeable_amount ASC NULLS FIRST LIMIT 1


Question:
Which company started the earliest the maintenance contract? Show the company name.
Additional table information: table: assets_maintenance

Answer: SELECT T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Contracts AS T2 ON T1.company_id = T2.maintenance_contract_company_id ORDER BY T2.contract_start_date ASC NULLS FIRST LIMIT 1


Question:
What is the description of the type of the company who concluded its contracts most recently?
Additional table information: table: assets_maintenance

Answer: SELECT T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Contracts AS T2 ON T1.company_id = T2.maintenance_contract_company_id JOIN Ref_Company_Types AS T3 ON T1.company_type_code = T3.company_type_code ORDER BY T2.contract_end_date DESC LIMIT 1


Question:
Which gender makes up the majority of the staff?
Additional table information: table: assets_maintenance

Answer: SELECT gender FROM staff GROUP BY gender ORDER BY COUNT(*) DESC LIMIT 1


Question:
How many engineers did each staff contact? List both the contact staff name and number of engineers contacted.
Additional table information: table: assets_maintenance

Answer: SELECT T1.staff_name, COUNT(*) FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id GROUP BY T1.staff_name


Question:
Which assets did not incur any fault log? List the asset model.
Additional table information: table: assets_maintenance

Answer: SELECT asset_model FROM Assets WHERE NOT asset_id IN (SELECT asset_id FROM Fault_Log)


Question:
list the local authorities and services provided by all stations.
Additional table information: table: station_weather

Answer: SELECT local_authority, services FROM station


Question:
show all train numbers and names ordered by their time from early to late.
Additional table information: table: station_weather

Answer: SELECT train_number, name FROM train ORDER BY TIME NULLS FIRST


Question:
Give me the times and numbers of all trains that go to Chennai, ordered by time.
Additional table information: table: station_weather

Answer: SELECT TIME, train_number FROM train WHERE destination = 'Chennai' ORDER BY TIME NULLS FIRST


Question:
How many trains have 'Express' in their names?
Additional table information: table: station_weather

Answer: SELECT COUNT(*) FROM train WHERE name LIKE '%Express%'


Question:
Find the number and time of the train that goes from Chennai to Guruvayur.
Additional table information: table: station_weather

Answer: SELECT train_number, TIME FROM train WHERE origin = 'Chennai' AND destination = 'Guruvayur'


Question:
Find the number of trains starting from each origin.
Additional table information: table: station_weather

Answer: SELECT origin, COUNT(*) FROM train GROUP BY origin


Question:
Find the name of the train whose route runs through greatest number of stations.
Additional table information: table: station_weather

Answer: SELECT t1.name FROM train AS t1 JOIN route AS t2 ON t1.id = t2.train_id GROUP BY t2.train_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the number of trains for each station, as well as the station network name and services.
Additional table information: table: station_weather

Answer: SELECT COUNT(*), t1.network_name, t1.services FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id GROUP BY t2.station_id


Question:
What is the average high temperature for each day of week?
Additional table information: table: station_weather

Answer: SELECT AVG(high_temperature), day_of_week FROM weekly_weather GROUP BY day_of_week


Question:
Give me the maximum low temperature and average precipitation at the Amersham station.
Additional table information: table: station_weather

Answer: SELECT MAX(t1.low_temperature), AVG(t1.precipitation) FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id WHERE t2.network_name = 'Amersham'


Question:
Find names and times of trains that run through stations for the local authority Chiltern.
Additional table information: table: station_weather

Answer: SELECT t3.name, t3.time FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id JOIN train AS t3 ON t2.train_id = t3.id WHERE t1.local_authority = 'Chiltern'


Question:
How many different services are provided by all stations?
Additional table information: table: station_weather

Answer: SELECT COUNT(DISTINCT services) FROM station


Question:
Find the id and local authority of the station with has the highest average high temperature.
Additional table information: table: station_weather

Answer: SELECT t2.id, t2.local_authority FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id GROUP BY t1.station_id ORDER BY AVG(high_temperature) DESC LIMIT 1


Question:
Find the id and local authority of the station whose maximum precipitation is higher than 50.
Additional table information: table: station_weather

Answer: SELECT t2.id, t2.local_authority FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id GROUP BY t1.station_id HAVING MAX(t1.precipitation) > 50


Question:
show the lowest low temperature and highest wind speed in miles per hour.
Additional table information: table: station_weather

Answer: SELECT MIN(low_temperature), MAX(wind_speed_mph) FROM weekly_weather


Question:
Find the origins from which more than 1 train starts.
Additional table information: table: station_weather

Answer: SELECT origin FROM train GROUP BY origin HAVING COUNT(*) > 1


Question:
Find the number of professors in accounting department.
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = 'Accounting'


Question:
How many professors are in the accounting dept?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = 'Accounting'


Question:
How many professors are teaching class with code ACCT-211?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = 'ACCT-211'


Question:
How many professors teach a class with the code ACCT-211?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = 'ACCT-211'


Question:
What is the first and last name of the professor in biology department?
Additional table information: table: college_1

Answer: SELECT T3.EMP_FNAME, T3.EMP_LNAME FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code JOIN employee AS T3 ON T1.EMP_NUM = T3.EMP_NUM WHERE DEPT_NAME = 'Biology'


Question:
What are the first and last name of all biology professors?
Additional table information: table: college_1

Answer: SELECT T3.EMP_FNAME, T3.EMP_LNAME FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code JOIN employee AS T3 ON T1.EMP_NUM = T3.EMP_NUM WHERE DEPT_NAME = 'Biology'


Question:
What are the first names and date of birth of professors teaching course ACCT-211?
Additional table information: table: college_1

Answer: SELECT DISTINCT T1.EMP_FNAME, T1.EMP_DOB FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE CRS_CODE = 'ACCT-211'


Question:
What are the first names and birthdates of the professors in charge of ACCT-211?
Additional table information: table: college_1

Answer: SELECT DISTINCT T1.EMP_FNAME, T1.EMP_DOB FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE CRS_CODE = 'ACCT-211'


Question:
How many classes are professor whose last name is Graztevski has?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski'


Question:
How many classes does the professor whose last name is Graztevski teach?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski'


Question:
What is the code of the school where the accounting department belongs to?
Additional table information: table: college_1

Answer: SELECT school_code FROM department WHERE dept_name = 'Accounting'


Question:
What is the school code of the accounting department?
Additional table information: table: college_1

Answer: SELECT school_code FROM department WHERE dept_name = 'Accounting'


Question:
How many credits does course CIS-220 have, and what its description?
Additional table information: table: college_1

Answer: SELECT crs_credit, crs_description FROM course WHERE crs_code = 'CIS-220'


Question:
What is the description for the CIS-220 and how many credits does it have?
Additional table information: table: college_1

Answer: SELECT crs_credit, crs_description FROM course WHERE crs_code = 'CIS-220'


Question:
what is the address of history department?
Additional table information: table: college_1

Answer: SELECT dept_address FROM department WHERE dept_name = 'History'


Question:
Where is the history department?
Additional table information: table: college_1

Answer: SELECT dept_address FROM department WHERE dept_name = 'History'


Question:
How many different locations does the school with code BUS has?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'


Question:
What are the different locations of the school with the code BUS?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'


Question:
How many different locations does each school have?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_address), school_code FROM department GROUP BY school_code


Question:
Count different addresses of each school.
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_address), school_code FROM department GROUP BY school_code


Question:
Find the description and credit for the course QM-261?
Additional table information: table: college_1

Answer: SELECT crs_credit, crs_description FROM course WHERE crs_code = 'QM-261'


Question:
What is the course description and number of credits for QM-261?
Additional table information: table: college_1

Answer: SELECT crs_credit, crs_description FROM course WHERE crs_code = 'QM-261'


Question:
Find the number of departments in each school.
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_name), school_code FROM department GROUP BY school_code


Question:
How many departments are in each school?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_name), school_code FROM department GROUP BY school_code


Question:
Find the number of different departments in each school whose number of different departments is less than 5.
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_name), school_code FROM department GROUP BY school_code HAVING COUNT(DISTINCT dept_name) < 5


Question:
How many different departments are there in each school that has less than 5 apartments?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_name), school_code FROM department GROUP BY school_code HAVING COUNT(DISTINCT dept_name) < 5


Question:
How many sections does each course has?
Additional table information: table: college_1

Answer: SELECT COUNT(*), crs_code FROM CLASS GROUP BY crs_code


Question:
How many sections does each course have?
Additional table information: table: college_1

Answer: SELECT COUNT(*), crs_code FROM CLASS GROUP BY crs_code


Question:
What is the total credit does each department offer?
Additional table information: table: college_1

Answer: SELECT SUM(crs_credit), dept_code FROM course GROUP BY dept_code


Question:
How many credits does the department offer?
Additional table information: table: college_1

Answer: SELECT SUM(crs_credit), dept_code FROM course GROUP BY dept_code


Question:
Find the number of classes offered for all class rooms that held at least 2 classes.
Additional table information: table: college_1

Answer: SELECT COUNT(*), class_room FROM CLASS GROUP BY class_room HAVING COUNT(*) >= 2


Question:
For each classroom with at least 2 classes, how many classes are offered?
Additional table information: table: college_1

Answer: SELECT COUNT(*), class_room FROM CLASS GROUP BY class_room HAVING COUNT(*) >= 2


Question:
Find the number of classes in each department.
Additional table information: table: college_1

Answer: SELECT COUNT(*), dept_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code GROUP BY dept_code


Question:
How many classes are held in each department?
Additional table information: table: college_1

Answer: SELECT COUNT(*), dept_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code GROUP BY dept_code


Question:
Find the number of classes in each school.
Additional table information: table: college_1

Answer: SELECT COUNT(*), T3.school_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T2.dept_code = T3.dept_code GROUP BY T3.school_code


Question:
How many classes exist for each school?
Additional table information: table: college_1

Answer: SELECT COUNT(*), T3.school_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T2.dept_code = T3.dept_code GROUP BY T3.school_code


Question:
What is the number of professors for different school?
Additional table information: table: college_1

Answer: SELECT COUNT(*), T1.school_code FROM department AS T1 JOIN professor AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.school_code


Question:
How many different professors are there for the different schools?
Additional table information: table: college_1

Answer: SELECT COUNT(*), T1.school_code FROM department AS T1 JOIN professor AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.school_code


Question:
Find the count and code of the job has most employees.
Additional table information: table: college_1

Answer: SELECT emp_jobcode, COUNT(*) FROM employee GROUP BY emp_jobcode ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the count and code of the job with the most employee?
Additional table information: table: college_1

Answer: SELECT emp_jobcode, COUNT(*) FROM employee GROUP BY emp_jobcode ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which school has the smallest amount of professors?
Additional table information: table: college_1

Answer: SELECT T1.school_code FROM department AS T1 JOIN professor AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.school_code ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
Which school has the fewest professors?
Additional table information: table: college_1

Answer: SELECT T1.school_code FROM department AS T1 JOIN professor AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.school_code ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
Find the number of professors with a Ph.D. degree in each department.
Additional table information: table: college_1

Answer: SELECT COUNT(*), dept_code FROM professor WHERE prof_high_degree = 'Ph.D.' GROUP BY dept_code


Question:
How many professors have a Ph.D. in each department?
Additional table information: table: college_1

Answer: SELECT COUNT(*), dept_code FROM professor WHERE prof_high_degree = 'Ph.D.' GROUP BY dept_code


Question:
Find the number of students for each department.
Additional table information: table: college_1

Answer: SELECT COUNT(*), dept_code FROM student GROUP BY dept_code


Question:
How many students are in each department?
Additional table information: table: college_1

Answer: SELECT COUNT(*), dept_code FROM student GROUP BY dept_code


Question:
Find the total number of hours have done for all students in each department.
Additional table information: table: college_1

Answer: SELECT SUM(stu_hrs), dept_code FROM student GROUP BY dept_code


Question:
How many hours do the students spend studying in each department?
Additional table information: table: college_1

Answer: SELECT SUM(stu_hrs), dept_code FROM student GROUP BY dept_code


Question:
Find the max, average, and minimum gpa of all students in each department.
Additional table information: table: college_1

Answer: SELECT MAX(stu_gpa), AVG(stu_gpa), MIN(stu_gpa), dept_code FROM student GROUP BY dept_code


Question:
What is the highest, lowest, and average student GPA for every department?
Additional table information: table: college_1

Answer: SELECT MAX(stu_gpa), AVG(stu_gpa), MIN(stu_gpa), dept_code FROM student GROUP BY dept_code


Question:
What is the name and the average gpa of department whose students have the highest average gpa?
Additional table information: table: college_1

Answer: SELECT T2.dept_name, AVG(T1.stu_gpa) FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY AVG(T1.stu_gpa) DESC LIMIT 1


Question:
Which department has the highest average student GPA, and what is the average gpa?
Additional table information: table: college_1

Answer: SELECT T2.dept_name, AVG(T1.stu_gpa) FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY AVG(T1.stu_gpa) DESC LIMIT 1


Question:
how many schools exist in total?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT school_code) FROM department


Question:
How many schools are there in the department?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT school_code) FROM department


Question:
How many different classes are there?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT class_code) FROM CLASS


Question:
How many unique classes are offered?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT class_code) FROM CLASS


Question:
How many courses are offered?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT crs_code) FROM CLASS


Question:
What are the number of different course codes?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT crs_code) FROM CLASS


Question:
How many departments does the college has?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_name) FROM department


Question:
How many different departments are there?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_name) FROM department


Question:
How many courses are offered by the Computer Info. Systems department?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM department AS T1 JOIN course AS T2 ON T1.dept_code = T2.dept_code WHERE dept_name = 'Computer Info. Systems'


Question:
How many courses does the department of Computer Information Systmes offer?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM department AS T1 JOIN course AS T2 ON T1.dept_code = T2.dept_code WHERE dept_name = 'Computer Info. Systems'


Question:
How many sections does course ACCT-211 has?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT class_section) FROM CLASS WHERE crs_code = 'ACCT-211'


Question:
What is the number of different class sections offered in the course ACCT-211?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT class_section) FROM CLASS WHERE crs_code = 'ACCT-211'


Question:
Find the total credits of all classes offered by each department.
Additional table information: table: college_1

Answer: SELECT SUM(T1.crs_credit), T1.dept_code FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code GROUP BY T1.dept_code


Question:
What are the total number of credits offered by each department?
Additional table information: table: college_1

Answer: SELECT SUM(T1.crs_credit), T1.dept_code FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code GROUP BY T1.dept_code


Question:
Find the name of the department that offers the largest number of credits of all classes.
Additional table information: table: college_1

Answer: SELECT T3.dept_name FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T1.dept_code = T3.dept_code GROUP BY T1.dept_code ORDER BY SUM(T1.crs_credit) DESC LIMIT 1


Question:
Which department offers the most credits all together?
Additional table information: table: college_1

Answer: SELECT T3.dept_name FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T1.dept_code = T3.dept_code GROUP BY T1.dept_code ORDER BY SUM(T1.crs_credit) DESC LIMIT 1


Question:
How many students enrolled in class ACCT-211?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code WHERE T1.crs_code = 'ACCT-211'


Question:
What are the total number of students enrolled in ACCT-211?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code WHERE T1.crs_code = 'ACCT-211'


Question:
What is the first name of each student enrolled in class ACCT-211?
Additional table information: table: college_1

Answer: SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211'


Question:
What are the first names of all students in course ACCT-211?
Additional table information: table: college_1

Answer: SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211'


Question:
What is the first name of students enrolled in class ACCT-211 and got grade C?
Additional table information: table: college_1

Answer: SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211' AND T2.enroll_grade = 'C'


Question:
What are the first names of all students who took ACCT-211 and received a C?
Additional table information: table: college_1

Answer: SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211' AND T2.enroll_grade = 'C'


Question:
Find the total number of employees.
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM employee


Question:
How many employees are there all together?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM employee


Question:
How many professors do have a Ph.D. degree?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM professor WHERE prof_high_degree = 'Ph.D.'


Question:
What is the total number of professors with a Ph.D. ?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM professor WHERE prof_high_degree = 'Ph.D.'


Question:
How many students are enrolled in the class taught by some professor from the accounting department?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code WHERE T4.dept_name = 'Accounting'


Question:
How many students are enrolled in some classes that are taught by an accounting professor?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code WHERE T4.dept_name = 'Accounting'


Question:
What is the name of the department that has the largest number of students enrolled?
Additional table information: table: college_1

Answer: SELECT T4.dept_name FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code GROUP BY T3.dept_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the name of the department with the most students enrolled?
Additional table information: table: college_1

Answer: SELECT T4.dept_name FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code GROUP BY T3.dept_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
list names of all departments ordered by their names.
Additional table information: table: college_1

Answer: SELECT dept_name FROM department ORDER BY dept_name NULLS FIRST


Question:
What are the names of all departments in alphabetical order?
Additional table information: table: college_1

Answer: SELECT dept_name FROM department ORDER BY dept_name NULLS FIRST