Question:
What are the details for the projects which were launched by the organization with the most projects?
Additional table information: table: tracking_grants_for_research

Answer: SELECT project_details FROM Projects WHERE organisation_id IN (SELECT organisation_id FROM Projects GROUP BY organisation_id ORDER BY COUNT(*) DESC LIMIT 1)


Question:
List the research staff details, and order in ascending order.
Additional table information: table: tracking_grants_for_research

Answer: SELECT staff_details FROM Research_Staff ORDER BY staff_details ASC NULLS FIRST


Question:
What details are there on the research staff? List the result in ascending alphabetical order.
Additional table information: table: tracking_grants_for_research

Answer: SELECT staff_details FROM Research_Staff ORDER BY staff_details ASC NULLS FIRST


Question:
How many tasks are there in total?
Additional table information: table: tracking_grants_for_research

Answer: SELECT COUNT(*) FROM Tasks


Question:
How many tasks are there?
Additional table information: table: tracking_grants_for_research

Answer: SELECT COUNT(*) FROM Tasks


Question:
How many tasks does each project have? List the task count and the project detail.
Additional table information: table: tracking_grants_for_research

Answer: SELECT COUNT(*), T1.project_details FROM Projects AS T1 JOIN Tasks AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id


Question:
For each project id, how many tasks are there?
Additional table information: table: tracking_grants_for_research

Answer: SELECT COUNT(*), T1.project_details FROM Projects AS T1 JOIN Tasks AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id


Question:
What are the staff roles of the staff who
Additional table information: table: tracking_grants_for_research

Answer: SELECT role_code FROM Project_Staff WHERE date_from > '2003-04-19 15:06:20' AND date_to < '2016-03-15 00:33:18'


Question:
What roles did staff members play between '2003-04-19 15:06:20' and '2016-03-15 00:33:18'?
Additional table information: table: tracking_grants_for_research

Answer: SELECT role_code FROM Project_Staff WHERE date_from > '2003-04-19 15:06:20' AND date_to < '2016-03-15 00:33:18'


Question:
What are the descriptions of all the project outcomes?
Additional table information: table: tracking_grants_for_research

Answer: SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code = T2.outcome_code


Question:
List the description of the outcomes for all projects.
Additional table information: table: tracking_grants_for_research

Answer: SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code = T2.outcome_code


Question:
Which role is most common for the staff?
Additional table information: table: tracking_grants_for_research

Answer: SELECT role_code FROM Project_Staff GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the most common role for the staff?
Additional table information: table: tracking_grants_for_research

Answer: SELECT role_code FROM Project_Staff GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
How many friends does Dan have?
Additional table information: table: network_2

Answer: SELECT COUNT(T2.friend) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Dan'


Question:
How many friends does Dan have?
Additional table information: table: network_2

Answer: SELECT COUNT(T2.friend) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Dan'


Question:
How many females does this network has?
Additional table information: table: network_2

Answer: SELECT COUNT(*) FROM Person WHERE gender = 'female'


Question:
How many females are in the network?
Additional table information: table: network_2

Answer: SELECT COUNT(*) FROM Person WHERE gender = 'female'


Question:
What is the average age for all person?
Additional table information: table: network_2

Answer: SELECT AVG(age) FROM Person


Question:
What is the average age for all people in the table?
Additional table information: table: network_2

Answer: SELECT AVG(age) FROM Person


Question:
How many different cities are they from?
Additional table information: table: network_2

Answer: SELECT COUNT(DISTINCT city) FROM Person


Question:
How many different cities do people originate from?
Additional table information: table: network_2

Answer: SELECT COUNT(DISTINCT city) FROM Person


Question:
How many type of jobs do they have?
Additional table information: table: network_2

Answer: SELECT COUNT(DISTINCT job) FROM Person


Question:
How many different jobs are listed?
Additional table information: table: network_2

Answer: SELECT COUNT(DISTINCT job) FROM Person


Question:
Who is the oldest person?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE age = (SELECT MAX(age) FROM person)


Question:
What is the name of the person who is the oldest?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE age = (SELECT MAX(age) FROM person)


Question:
Who is the oldest person whose job is student?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE job = 'student' AND age = (SELECT MAX(age) FROM person WHERE job = 'student')


Question:
What is the name of the oldest student?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE job = 'student' AND age = (SELECT MAX(age) FROM person WHERE job = 'student')


Question:
Who is the youngest male?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE gender = 'male' AND age = (SELECT MIN(age) FROM person WHERE gender = 'male')


Question:
What is the name of the youngest male?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE gender = 'male' AND age = (SELECT MIN(age) FROM person WHERE gender = 'male')


Question:
How old is the doctor named Zach?
Additional table information: table: network_2

Answer: SELECT age FROM Person WHERE job = 'doctor' AND name = 'Zach'


Question:
What is the age of the doctor named Zach?
Additional table information: table: network_2

Answer: SELECT age FROM Person WHERE job = 'doctor' AND name = 'Zach'


Question:
Who is the person whose age is below 30?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE age < 30


Question:
What is the name of the person whose age is below 30?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE age < 30


Question:
How many people whose age is greater 30 and job is engineer?
Additional table information: table: network_2

Answer: SELECT COUNT(*) FROM Person WHERE age > 30 AND job = 'engineer'


Question:
HOw many engineers are older than 30?
Additional table information: table: network_2

Answer: SELECT COUNT(*) FROM Person WHERE age > 30 AND job = 'engineer'


Question:
What is the average age for each gender?
Additional table information: table: network_2

Answer: SELECT AVG(age), gender FROM Person GROUP BY gender


Question:
How old is each gender, on average?
Additional table information: table: network_2

Answer: SELECT AVG(age), gender FROM Person GROUP BY gender


Question:
What is average age for different job title?
Additional table information: table: network_2

Answer: SELECT AVG(age), job FROM Person GROUP BY job


Question:
How old is the average person for each job?
Additional table information: table: network_2

Answer: SELECT AVG(age), job FROM Person GROUP BY job


Question:
What is average age of male for different job title?
Additional table information: table: network_2

Answer: SELECT AVG(age), job FROM Person WHERE gender = 'male' GROUP BY job


Question:
What is the average age for a male in each job?
Additional table information: table: network_2

Answer: SELECT AVG(age), job FROM Person WHERE gender = 'male' GROUP BY job


Question:
What is minimum age for different job title?
Additional table information: table: network_2

Answer: SELECT MIN(age), job FROM Person GROUP BY job


Question:
How old is the youngest person for each job?
Additional table information: table: network_2

Answer: SELECT MIN(age), job FROM Person GROUP BY job


Question:
Find the number of people who is under 40 for each gender.
Additional table information: table: network_2

Answer: SELECT COUNT(*), gender FROM Person WHERE age < 40 GROUP BY gender


Question:
How many people are under 40 for each gender?
Additional table information: table: network_2

Answer: SELECT COUNT(*), gender FROM Person WHERE age < 40 GROUP BY gender


Question:
Find the name of people whose age is greater than any engineer sorted by their age.
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE age > (SELECT MIN(age) FROM person WHERE job = 'engineer') ORDER BY age NULLS FIRST


Question:
What is the name of all the people who are older than at least one engineer? Order them by age.
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE age > (SELECT MIN(age) FROM person WHERE job = 'engineer') ORDER BY age NULLS FIRST


Question:
Find the number of people whose age is greater than all engineers.
Additional table information: table: network_2

Answer: SELECT COUNT(*) FROM Person WHERE age > (SELECT MAX(age) FROM person WHERE job = 'engineer')


Question:
How many people are older than every engineer?
Additional table information: table: network_2

Answer: SELECT COUNT(*) FROM Person WHERE age > (SELECT MAX(age) FROM person WHERE job = 'engineer')


Question:
list the name, job title of all people ordered by their names.
Additional table information: table: network_2

Answer: SELECT name, job FROM Person ORDER BY name NULLS FIRST


Question:
What are the names and job titles of every person ordered alphabetically by name?
Additional table information: table: network_2

Answer: SELECT name, job FROM Person ORDER BY name NULLS FIRST


Question:
Find the names of all person sorted in the descending order using age.
Additional table information: table: network_2

Answer: SELECT name FROM Person ORDER BY age DESC


Question:
What are the names of everybody sorted by age in descending order?
Additional table information: table: network_2

Answer: SELECT name FROM Person ORDER BY age DESC


Question:
Find the name and age of all males in order of their age.
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE gender = 'male' ORDER BY age NULLS FIRST


Question:
What is the name and age of every male? Order the results by age.
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE gender = 'male' ORDER BY age NULLS FIRST


Question:
Find the name and age of the person who is a friend of both Dan and Alice.
Additional table information: table: network_2

Answer: SELECT T1.name, T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Dan' INTERSECT SELECT T1.name, T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Alice'


Question:
What are the names and ages of every person who is a friend of both Dan and Alice?
Additional table information: table: network_2

Answer: SELECT T1.name, T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Dan' INTERSECT SELECT T1.name, T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Alice'


Question:
Find the name and age of the person who is a friend of Dan or Alice.
Additional table information: table: network_2

Answer: SELECT DISTINCT T1.name, T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Dan' OR T2.friend = 'Alice'


Question:
What are the different names and ages of every friend of either Dan or alice?
Additional table information: table: network_2

Answer: SELECT DISTINCT T1.name, T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Dan' OR T2.friend = 'Alice'


Question:
Find the name of the person who has friends with age above 40 and under age 30?
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30)


Question:
What are the names of every person who has a friend over 40 and under 30?
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30)


Question:
Find the name of the person who has friends with age above 40 but not under age 30?
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) EXCEPT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30)


Question:
What are the names of the people who are older 40 but no friends under age 30?
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) EXCEPT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30)


Question:
Find the name of the person who has no student friends.
Additional table information: table: network_2

Answer: SELECT name FROM person EXCEPT SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.job = 'student'


Question:
What are the names of the people who have no friends who are students?
Additional table information: table: network_2

Answer: SELECT name FROM person EXCEPT SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.job = 'student'


Question:
Find the person who has exactly one friend.
Additional table information: table: network_2

Answer: SELECT name FROM PersonFriend GROUP BY name HAVING COUNT(*) = 1


Question:
What are the names of everybody who has exactly one friend?
Additional table information: table: network_2

Answer: SELECT name FROM PersonFriend GROUP BY name HAVING COUNT(*) = 1


Question:
Who are the friends of Bob?
Additional table information: table: network_2

Answer: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Bob'


Question:
Who are Bob's friends?
Additional table information: table: network_2

Answer: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Bob'


Question:
Find the name of persons who are friends with Bob.
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Bob'


Question:
What are the names of all of Bob's friends?
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Bob'


Question:
Find the names of females who are friends with Zach
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Zach' AND T1.gender = 'female'


Question:
What are the names of all females who are friends with Zach?
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Zach' AND T1.gender = 'female'


Question:
Find the female friends of Alice.
Additional table information: table: network_2

Answer: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Alice' AND T1.gender = 'female'


Question:
What are all the friends of Alice who are female?
Additional table information: table: network_2

Answer: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Alice' AND T1.gender = 'female'


Question:
Find the male friend of Alice whose job is a doctor?
Additional table information: table: network_2

Answer: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Alice' AND T1.gender = 'male' AND T1.job = 'doctor'


Question:
Who are the friends of Alice that are doctors?
Additional table information: table: network_2

Answer: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Alice' AND T1.gender = 'male' AND T1.job = 'doctor'


Question:
Who has a friend that is from new york city?
Additional table information: table: network_2

Answer: SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.city = 'new york city'


Question:
What are the names of all friends who are from New York?
Additional table information: table: network_2

Answer: SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.city = 'new york city'


Question:
Who has friends that are younger than the average age?
Additional table information: table: network_2

Answer: SELECT DISTINCT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.age < (SELECT AVG(age) FROM person)


Question:
What are the different names of friends who are younger than the average age for a friend?
Additional table information: table: network_2

Answer: SELECT DISTINCT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.age < (SELECT AVG(age) FROM person)


Question:
Who has friends that are older than the average age? Print their friends and their ages as well
Additional table information: table: network_2

Answer: SELECT DISTINCT T2.name, T2.friend, T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.age > (SELECT AVG(age) FROM person)


Question:
Whare the names, friends, and ages of all people who are older than the average age of a person?
Additional table information: table: network_2

Answer: SELECT DISTINCT T2.name, T2.friend, T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.age > (SELECT AVG(age) FROM person)


Question:
Who is the friend of Zach with longest year relationship?
Additional table information: table: network_2

Answer: SELECT friend FROM PersonFriend WHERE name = 'Zach' AND YEAR = (SELECT MAX(YEAR) FROM PersonFriend WHERE name = 'Zach')


Question:
Which friend of Zach has the longest-lasting friendship?
Additional table information: table: network_2

Answer: SELECT friend FROM PersonFriend WHERE name = 'Zach' AND YEAR = (SELECT MAX(YEAR) FROM PersonFriend WHERE name = 'Zach')


Question:
What is the age of the friend of Zach with longest year relationship?
Additional table information: table: network_2

Answer: SELECT T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Zach' AND T2.year = (SELECT MAX(YEAR) FROM PersonFriend WHERE name = 'Zach')


Question:
What are the ages of all of Zach's friends who are in the longest relationship?
Additional table information: table: network_2

Answer: SELECT T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Zach' AND T2.year = (SELECT MAX(YEAR) FROM PersonFriend WHERE name = 'Zach')


Question:
Find the name of persons who are friends with Alice for the shortest years.
Additional table information: table: network_2

Answer: SELECT name FROM PersonFriend WHERE friend = 'Alice' AND YEAR = (SELECT MIN(YEAR) FROM PersonFriend WHERE friend = 'Alice')


Question:
What are the names of all people who are friends with Alice for the shortest amount of time?
Additional table information: table: network_2

Answer: SELECT name FROM PersonFriend WHERE friend = 'Alice' AND YEAR = (SELECT MIN(YEAR) FROM PersonFriend WHERE friend = 'Alice')


Question:
Find the name, age, and job title of persons who are friends with Alice for the longest years.
Additional table information: table: network_2

Answer: SELECT T1.name, T1.age, T1.job FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Alice' AND T2.year = (SELECT MAX(YEAR) FROM PersonFriend WHERE friend = 'Alice')


Question:
What are the names, ages, and jobs of all people who are friends with Alice for the longest amount of time?
Additional table information: table: network_2

Answer: SELECT T1.name, T1.age, T1.job FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Alice' AND T2.year = (SELECT MAX(YEAR) FROM PersonFriend WHERE friend = 'Alice')


Question:
Who is the person that has no friend?
Additional table information: table: network_2

Answer: SELECT name FROM person EXCEPT SELECT name FROM PersonFriend


Question:
What are the names of all people who do not have friends?
Additional table information: table: network_2

Answer: SELECT name FROM person EXCEPT SELECT name FROM PersonFriend


Question:
Which person whose friends have the oldest average age?
Additional table information: table: network_2

Answer: SELECT T2.name, AVG(T1.age) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend GROUP BY T2.name ORDER BY AVG(T1.age) DESC LIMIT 1


Question:
What is the name of the person who has the oldest average age for their friends, and what is that average age?
Additional table information: table: network_2

Answer: SELECT T2.name, AVG(T1.age) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend GROUP BY T2.name ORDER BY AVG(T1.age) DESC LIMIT 1


Question:
What is the total number of people who has no friend living in the city of Austin.
Additional table information: table: network_2

Answer: SELECT COUNT(DISTINCT name) FROM PersonFriend WHERE NOT friend IN (SELECT name FROM person WHERE city = 'Austin')


Question:
What is the total number of people who have no friends living in Austin?
Additional table information: table: network_2

Answer: SELECT COUNT(DISTINCT name) FROM PersonFriend WHERE NOT friend IN (SELECT name FROM person WHERE city = 'Austin')


Question:
Find Alice's friends of friends.
Additional table information: table: network_2

Answer: SELECT DISTINCT T4.name FROM PersonFriend AS T1 JOIN Person AS T2 ON T1.name = T2.name JOIN PersonFriend AS T3 ON T1.friend = T3.name JOIN PersonFriend AS T4 ON T3.friend = T4.name WHERE T2.name = 'Alice' AND T4.name <> 'Alice'


Question:
What are the names of all of Alice's friends of friends?
Additional table information: table: network_2

Answer: SELECT DISTINCT T4.name FROM PersonFriend AS T1 JOIN Person AS T2 ON T1.name = T2.name JOIN PersonFriend AS T3 ON T1.friend = T3.name JOIN PersonFriend AS T4 ON T3.friend = T4.name WHERE T2.name = 'Alice' AND T4.name <> 'Alice'


Question:
How many members are there?
Additional table information: table: decoration_competition

Answer: SELECT COUNT(*) FROM member


Question:
List the names of members in ascending alphabetical order.
Additional table information: table: decoration_competition

Answer: SELECT Name FROM member ORDER BY Name ASC NULLS FIRST


Question:
What are the names and countries of members?
Additional table information: table: decoration_competition

Answer: SELECT Name, Country FROM member


Question:
Show the names of members whose country is 'United States' or 'Canada'.
Additional table information: table: decoration_competition

Answer: SELECT Name FROM member WHERE Country = 'United States' OR Country = 'Canada'


Question:
Show the different countries and the number of members from each.
Additional table information: table: decoration_competition

Answer: SELECT Country, COUNT(*) FROM member GROUP BY Country


Question:
Show the most common country across members.
Additional table information: table: decoration_competition

Answer: SELECT Country FROM member GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which countries have more than two members?
Additional table information: table: decoration_competition

Answer: SELECT Country FROM member GROUP BY Country HAVING COUNT(*) > 2


Question:
Show the leader names and locations of colleges.
Additional table information: table: decoration_competition

Answer: SELECT Leader_Name, College_Location FROM college


Question:
Show the names of members and names of colleges they go to.
Additional table information: table: decoration_competition

Answer: SELECT T2.Name, T1.Name FROM college AS T1 JOIN member AS T2 ON T1.College_ID = T2.College_ID


Question:
Show the names of members and the locations of colleges they go to in ascending alphabetical order of member names.
Additional table information: table: decoration_competition

Answer: SELECT T2.Name, T1.College_Location FROM college AS T1 JOIN member AS T2 ON T1.College_ID = T2.College_ID ORDER BY T2.Name ASC NULLS FIRST


Question:
Show the distinct leader names of colleges associated with members from country 'Canada'.
Additional table information: table: decoration_competition

Answer: SELECT DISTINCT T1.Leader_Name FROM college AS T1 JOIN member AS T2 ON T1.College_ID = T2.College_ID WHERE T2.Country = 'Canada'


Question:
Show the names of members and the decoration themes they have.
Additional table information: table: decoration_competition

Answer: SELECT T1.Name, T2.Decoration_Theme FROM member AS T1 JOIN round AS T2 ON T1.Member_ID = T2.Member_ID


Question:
Show the names of members that have a rank in round higher than 3.
Additional table information: table: decoration_competition

Answer: SELECT T1.Name FROM member AS T1 JOIN round AS T2 ON T1.Member_ID = T2.Member_ID WHERE T2.Rank_in_Round > 3


Question:
Show the names of members in ascending order of their rank in rounds.
Additional table information: table: decoration_competition

Answer: SELECT T1.Name FROM member AS T1 JOIN round AS T2 ON T1.Member_ID = T2.Member_ID ORDER BY Rank_in_Round ASC NULLS FIRST


Question:
List the names of members who did not participate in any round.
Additional table information: table: decoration_competition

Answer: SELECT Name FROM member WHERE NOT Member_ID IN (SELECT Member_ID FROM round)


Question:
Find the name and access counts of all documents, in alphabetic order of the document name.
Additional table information: table: document_management

Answer: SELECT document_name, access_count FROM documents ORDER BY document_name NULLS FIRST


Question:
What are the names of all the documents, as well as the access counts of each, ordered alphabetically?
Additional table information: table: document_management

Answer: SELECT document_name, access_count FROM documents ORDER BY document_name NULLS FIRST


Question:
Find the name of the document that has been accessed the greatest number of times, as well as the count of how many times it has been accessed?
Additional table information: table: document_management

Answer: SELECT document_name, access_count FROM documents ORDER BY access_count DESC LIMIT 1


Question:
What is the name of the document which has been accessed the most times, as well as the number of times it has been accessed?
Additional table information: table: document_management

Answer: SELECT document_name, access_count FROM documents ORDER BY access_count DESC LIMIT 1


Question:
Find the types of documents with more than 4 documents.
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING COUNT(*) > 4


Question:
What are the codes of types of documents of which there are for or more?
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING COUNT(*) > 4


Question:
Find the total access count of all documents in the most popular document type.
Additional table information: table: document_management

Answer: SELECT SUM(access_count) FROM documents GROUP BY document_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the total access count of documents that are of the most common document type?
Additional table information: table: document_management

Answer: SELECT SUM(access_count) FROM documents GROUP BY document_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the average access count of documents?
Additional table information: table: document_management

Answer: SELECT AVG(access_count) FROM documents


Question:
Find the average access count across all documents?
Additional table information: table: document_management

Answer: SELECT AVG(access_count) FROM documents


Question:
What is the structure of the document with the least number of accesses?
Additional table information: table: document_management

Answer: SELECT t2.document_structure_description FROM documents AS t1 JOIN document_structures AS t2 ON t1.document_structure_code = t2.document_structure_code GROUP BY t1.document_structure_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Return the structure description of the document that has been accessed the fewest number of times.
Additional table information: table: document_management

Answer: SELECT t2.document_structure_description FROM documents AS t1 JOIN document_structures AS t2 ON t1.document_structure_code = t2.document_structure_code GROUP BY t1.document_structure_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the type of the document named 'David CV'?
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents WHERE document_name = 'David CV'


Question:
Return the type code of the document named 'David CV'.
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents WHERE document_name = 'David CV'


Question:
Find the list of documents that are both in the most three popular type and have the most three popular structure.
Additional table information: table: document_management

Answer: SELECT document_name FROM documents GROUP BY document_type_code ORDER BY COUNT(*) DESC LIMIT 3 INTERSECT SELECT document_name FROM documents GROUP BY document_structure_code ORDER BY COUNT(*) DESC LIMIT 3


Question:
What are the names of documents that have both one of the three most common types and one of three most common structures?
Additional table information: table: document_management

Answer: SELECT document_name FROM documents GROUP BY document_type_code ORDER BY COUNT(*) DESC LIMIT 3 INTERSECT SELECT document_name FROM documents GROUP BY document_structure_code ORDER BY COUNT(*) DESC LIMIT 3


Question:
What document types do have more than 10000 total access number.
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING SUM(access_count) > 10000


Question:
Return the codes of the document types that do not have a total access count of over 10000.
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING SUM(access_count) > 10000


Question:
What are all the section titles of the document named 'David CV'?
Additional table information: table: document_management

Answer: SELECT t2.section_title FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code WHERE t1.document_name = 'David CV'


Question:
Give the section titles of the document with the name 'David CV'.
Additional table information: table: document_management

Answer: SELECT t2.section_title FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code WHERE t1.document_name = 'David CV'


Question:
Find all the name of documents without any sections.
Additional table information: table: document_management

Answer: SELECT document_name FROM documents WHERE NOT document_code IN (SELECT document_code FROM document_sections)


Question:
What are the names of documents that do not have any sections?
Additional table information: table: document_management

Answer: SELECT document_name FROM documents WHERE NOT document_code IN (SELECT document_code FROM document_sections)


Question:
List all the username and passwords of users with the most popular role.
Additional table information: table: document_management

Answer: SELECT user_name, password FROM users GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the usernames and passwords of users that have the most common role?
Additional table information: table: document_management

Answer: SELECT user_name, password FROM users GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the average access counts of documents with functional area 'Acknowledgement'.
Additional table information: table: document_management

Answer: SELECT AVG(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code = t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code = t3.functional_area_code WHERE t3.functional_area_description = 'Acknowledgement'


Question:
What are the average access counts of documents that have the functional area description 'Acknowledgement'?
Additional table information: table: document_management

Answer: SELECT AVG(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code = t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code = t3.functional_area_code WHERE t3.functional_area_description = 'Acknowledgement'


Question:
Find names of the document without any images.
Additional table information: table: document_management

Answer: SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code JOIN document_sections_images AS t3 ON t2.section_id = t3.section_id


Question:
What are the names of documents that do not have any images?
Additional table information: table: document_management

Answer: SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code JOIN document_sections_images AS t3 ON t2.section_id = t3.section_id


Question:
What is the name of the document with the most number of sections?
Additional table information: table: document_management

Answer: SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code GROUP BY t1.document_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Return the name of the document that has the most sections.
Additional table information: table: document_management

Answer: SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code = t2.document_code GROUP BY t1.document_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
List all the document names which contains 'CV'.
Additional table information: table: document_management

Answer: SELECT document_name FROM documents WHERE document_name LIKE '%CV%'


Question:
What are the names of documents that contain the substring 'CV'?
Additional table information: table: document_management

Answer: SELECT document_name FROM documents WHERE document_name LIKE '%CV%'


Question:
How many users are logged in?
Additional table information: table: document_management

Answer: SELECT COUNT(*) FROM users WHERE user_login = 1


Question:
Count the number of users that are logged in.
Additional table information: table: document_management

Answer: SELECT COUNT(*) FROM users WHERE user_login = 1


Question:
Find the description of the most popular role among the users that have logged in.
Additional table information: table: document_management

Answer: SELECT role_description FROM ROLES WHERE role_code = (SELECT role_code FROM users WHERE user_login = 1 GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1)


Question:
What is the description of the most popular role among users that have logged in?
Additional table information: table: document_management

Answer: SELECT role_description FROM ROLES WHERE role_code = (SELECT role_code FROM users WHERE user_login = 1 GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1)


Question:
Find the average access count of documents with the least popular structure.
Additional table information: table: document_management

Answer: SELECT AVG(access_count) FROM documents GROUP BY document_structure_code ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
What is the average access count of documents that have the least common structure?
Additional table information: table: document_management

Answer: SELECT AVG(access_count) FROM documents GROUP BY document_structure_code ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
List all the image name and URLs in the order of their names.
Additional table information: table: document_management

Answer: SELECT image_name, image_url FROM images ORDER BY image_name NULLS FIRST


Question:
What are the names and urls of images, sorted alphabetically?
Additional table information: table: document_management

Answer: SELECT image_name, image_url FROM images ORDER BY image_name NULLS FIRST


Question:
Find the number of users in each role.
Additional table information: table: document_management

Answer: SELECT COUNT(*), role_code FROM users GROUP BY role_code


Question:
What are the different role codes for users, and how many users have each?
Additional table information: table: document_management

Answer: SELECT COUNT(*), role_code FROM users GROUP BY role_code


Question:
What document types have more than 2 corresponding documents?
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING COUNT(*) > 2


Question:
Give the codes of document types that have more than 2 corresponding documents.
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING COUNT(*) > 2


Question:
How many companies are there?
Additional table information: table: company_office

Answer: SELECT COUNT(*) FROM Companies


Question:
Count the number of companies.
Additional table information: table: company_office

Answer: SELECT COUNT(*) FROM Companies


Question:
List the names of companies in descending order of market value.
Additional table information: table: company_office

Answer: SELECT name FROM Companies ORDER BY Market_Value_billion DESC


Question:
Sort the company names in descending order of the company's market value.
Additional table information: table: company_office

Answer: SELECT name FROM Companies ORDER BY Market_Value_billion DESC


Question:
What are the names of companies whose headquarters are not 'USA'?
Additional table information: table: company_office

Answer: SELECT name FROM Companies WHERE Headquarters <> 'USA'


Question:
Find the names of the companies whose headquarters are not located in 'USA'.
Additional table information: table: company_office

Answer: SELECT name FROM Companies WHERE Headquarters <> 'USA'


Question:
What are the name and assets of each company, sorted in ascending order of company name?
Additional table information: table: company_office

Answer: SELECT name, Assets_billion FROM Companies ORDER BY name ASC NULLS FIRST


Question:
List the name and assets of each company in ascending order of company name.
Additional table information: table: company_office

Answer: SELECT name, Assets_billion FROM Companies ORDER BY name ASC NULLS FIRST


Question:
What are the average profits of companies?
Additional table information: table: company_office

Answer: SELECT AVG(Profits_billion) FROM Companies


Question:
Compute the average profits companies make.
Additional table information: table: company_office

Answer: SELECT AVG(Profits_billion) FROM Companies


Question:
What are the maximum and minimum sales of the companies whose industries are not 'Banking'.
Additional table information: table: company_office

Answer: SELECT MAX(Sales_billion), MIN(Sales_billion) FROM Companies WHERE Industry <> 'Banking'


Question:
Find the maximum and minimum sales of the companies that are not in the 'Banking' industry.
Additional table information: table: company_office

Answer: SELECT MAX(Sales_billion), MIN(Sales_billion) FROM Companies WHERE Industry <> 'Banking'


Question:
How many different industries are the companies in?
Additional table information: table: company_office

Answer: SELECT COUNT(DISTINCT Industry) FROM Companies


Question:
Count the number of distinct company industries.
Additional table information: table: company_office

Answer: SELECT COUNT(DISTINCT Industry) FROM Companies


Question:
List the names of buildings in descending order of building height.
Additional table information: table: company_office

Answer: SELECT name FROM buildings ORDER BY Height DESC


Question:
What are the names of buildings sorted in descending order of building height?
Additional table information: table: company_office

Answer: SELECT name FROM buildings ORDER BY Height DESC


Question:
Find the stories of the building with the largest height.
Additional table information: table: company_office

Answer: SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1


Question:
What is the stories of highest building?
Additional table information: table: company_office

Answer: SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1


Question:
List the name of a building along with the name of a company whose office is in the building.
Additional table information: table: company_office

Answer: SELECT T3.name, T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id


Question:
For each company, return the company name and the name of the building its office is located in.
Additional table information: table: company_office

Answer: SELECT T3.name, T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id


Question:
Show the names of the buildings that have more than one company offices.
Additional table information: table: company_office

Answer: SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id HAVING COUNT(*) > 1


Question:
Which buildings have more than one company offices? Give me the building names.
Additional table information: table: company_office

Answer: SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id HAVING COUNT(*) > 1


Question:
Show the name of the building that has the most company offices.
Additional table information: table: company_office

Answer: SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which building has the largest number of company offices? Give me the building name.
Additional table information: table: company_office

Answer: SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Please show the names of the buildings whose status is 'on-hold', in ascending order of stories.
Additional table information: table: company_office

Answer: SELECT name FROM buildings WHERE Status = 'on-hold' ORDER BY Stories ASC NULLS FIRST


Question:
Find the names of the buildings in 'on-hold' status, and sort them in ascending order of building stories.
Additional table information: table: company_office

Answer: SELECT name FROM buildings WHERE Status = 'on-hold' ORDER BY Stories ASC NULLS FIRST


Question:
Please show each industry and the corresponding number of companies in that industry.
Additional table information: table: company_office

Answer: SELECT Industry, COUNT(*) FROM Companies GROUP BY Industry


Question:
Whah are the name of each industry and the number of companies in that industry?
Additional table information: table: company_office

Answer: SELECT Industry, COUNT(*) FROM Companies GROUP BY Industry


Question:
Please show the industries of companies in descending order of the number of companies.
Additional table information: table: company_office

Answer: SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC


Question:
Sort all the industries in descending order of the count of companies in each industry
Additional table information: table: company_office

Answer: SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC


Question:
List the industry shared by the most companies.
Additional table information: table: company_office

Answer: SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which industry has the most companies?
Additional table information: table: company_office

Answer: SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the names of buildings that have no company office.
Additional table information: table: company_office

Answer: SELECT name FROM buildings WHERE NOT id IN (SELECT building_id FROM Office_locations)


Question:
Which buildings do not have any company office? Give me the building names.
Additional table information: table: company_office

Answer: SELECT name FROM buildings WHERE NOT id IN (SELECT building_id FROM Office_locations)


Question:
Show the industries shared by companies whose headquarters are 'USA' and companies whose headquarters are 'China'.
Additional table information: table: company_office

Answer: SELECT Industry FROM Companies WHERE Headquarters = 'USA' INTERSECT SELECT Industry FROM Companies WHERE Headquarters = 'China'


Question:
Which industries have both companies with headquarter in 'USA' and companies with headquarter in 'China'?
Additional table information: table: company_office

Answer: SELECT Industry FROM Companies WHERE Headquarters = 'USA' INTERSECT SELECT Industry FROM Companies WHERE Headquarters = 'China'


Question:
Find the number of companies whose industry is 'Banking' or 'Conglomerate',
Additional table information: table: company_office

Answer: SELECT COUNT(*) FROM Companies WHERE Industry = 'Banking' OR Industry = 'Conglomerate'


Question:
How many companies are in either 'Banking' industry or 'Conglomerate' industry?
Additional table information: table: company_office

Answer: SELECT COUNT(*) FROM Companies WHERE Industry = 'Banking' OR Industry = 'Conglomerate'


Question:
Show the headquarters shared by more than two companies.
Additional table information: table: company_office

Answer: SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2


Question:
Which headquarter locations are used by more than 2 companies?
Additional table information: table: company_office

Answer: SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*) > 2


Question:
How many products are there?
Additional table information: table: solvency_ii

Answer: SELECT COUNT(*) FROM Products


Question:
List the name of products in ascending order of price.
Additional table information: table: solvency_ii

Answer: SELECT Product_Name FROM Products ORDER BY Product_Price ASC NULLS FIRST


Question:
What are the names and type codes of products?
Additional table information: table: solvency_ii

Answer: SELECT Product_Name, Product_Type_Code FROM Products


Question:
Show the prices of the products named 'Dining' or 'Trading Policy'.
Additional table information: table: solvency_ii

Answer: SELECT Product_Price FROM Products WHERE Product_Name = 'Dining' OR Product_Name = 'Trading Policy'


Question:
What is the average price for products?
Additional table information: table: solvency_ii

Answer: SELECT AVG(Product_Price) FROM Products


Question:
What is the name of the product with the highest price?
Additional table information: table: solvency_ii

Answer: SELECT Product_Name FROM Products ORDER BY Product_Price DESC LIMIT 1


Question:
Show different type codes of products and the number of products with each type code.
Additional table information: table: solvency_ii

Answer: SELECT Product_Type_Code, COUNT(*) FROM Products GROUP BY Product_Type_Code


Question:
Show the most common type code across products.
Additional table information: table: solvency_ii

Answer: SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Show the product type codes that have at least two products.
Additional table information: table: solvency_ii

Answer: SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*) >= 2


Question:
Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000.
Additional table information: table: solvency_ii

Answer: SELECT Product_Type_Code FROM Products WHERE Product_Price > 4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price < 3000


Question:
Show the names of products and the number of events they are in.
Additional table information: table: solvency_ii

Answer: SELECT T1.Product_Name, COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name


Question:
Show the names of products and the number of events they are in, sorted by the number of events in descending order.
Additional table information: table: solvency_ii

Answer: SELECT T1.Product_Name, COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name ORDER BY COUNT(*) DESC


Question:
Show the names of products that are in at least two events.
Additional table information: table: solvency_ii

Answer: SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*) >= 2


Question:
Show the names of products that are in at least two events in ascending alphabetical order of product name.
Additional table information: table: solvency_ii

Answer: SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID = T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*) >= 2 ORDER BY T1.Product_Name NULLS FIRST


Question:
List the names of products that are not in any event.
Additional table information: table: solvency_ii

Answer: SELECT Product_Name FROM Products WHERE NOT Product_ID IN (SELECT Product_ID FROM Products_in_Events)


Question:
How many artworks are there?
Additional table information: table: entertainment_awards

Answer: SELECT COUNT(*) FROM artwork


Question:
List the name of artworks in ascending alphabetical order.
Additional table information: table: entertainment_awards

Answer: SELECT Name FROM artwork ORDER BY Name ASC NULLS FIRST


Question:
List the name of artworks whose type is not 'Program Talent Show'.
Additional table information: table: entertainment_awards

Answer: SELECT Name FROM artwork WHERE TYPE <> 'Program Talent Show'


Question:
What are the names and locations of festivals?
Additional table information: table: entertainment_awards

Answer: SELECT Festival_Name, LOCATION FROM festival_detail


Question:
What are the names of the chairs of festivals, sorted in ascending order of the year held?
Additional table information: table: entertainment_awards

Answer: SELECT Chair_Name FROM festival_detail ORDER BY YEAR ASC NULLS FIRST


Question:
What is the location of the festival with the largest number of audience?
Additional table information: table: entertainment_awards

Answer: SELECT LOCATION FROM festival_detail ORDER BY Num_of_Audience DESC LIMIT 1


Question:
What are the names of festivals held in year 2007?
Additional table information: table: entertainment_awards

Answer: SELECT Festival_Name FROM festival_detail WHERE YEAR = 2007


Question:
What is the average number of audience for festivals?
Additional table information: table: entertainment_awards

Answer: SELECT AVG(Num_of_Audience) FROM festival_detail


Question:
Show the names of the three most recent festivals.
Additional table information: table: entertainment_awards

Answer: SELECT Festival_Name FROM festival_detail ORDER BY YEAR DESC LIMIT 3


Question:
For each nomination, show the name of the artwork and name of the festival where it is nominated.
Additional table information: table: entertainment_awards

Answer: SELECT T2.Name, T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID


Question:
Show distinct types of artworks that are nominated in festivals in 2007.
Additional table information: table: entertainment_awards

Answer: SELECT DISTINCT T2.Type FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID WHERE T3.Year = 2007


Question:
Show the names of artworks in ascending order of the year they are nominated in.
Additional table information: table: entertainment_awards

Answer: SELECT T2.Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID ORDER BY T3.Year NULLS FIRST


Question:
Show the names of festivals that have nominated artworks of type 'Program Talent Show'.
Additional table information: table: entertainment_awards

Answer: SELECT T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID WHERE T2.Type = 'Program Talent Show'


Question:
Show the ids and names of festivals that have at least two nominations for artworks.
Additional table information: table: entertainment_awards

Answer: SELECT T1.Festival_ID, T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID GROUP BY T1.Festival_ID HAVING COUNT(*) >= 2


Question:
Show the id, name of each festival and the number of artworks it has nominated.
Additional table information: table: entertainment_awards

Answer: SELECT T1.Festival_ID, T3.Festival_Name, COUNT(*) FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID GROUP BY T1.Festival_ID


Question:
Please show different types of artworks with the corresponding number of artworks of each type.
Additional table information: table: entertainment_awards

Answer: SELECT TYPE, COUNT(*) FROM artwork GROUP BY TYPE


Question:
List the most common type of artworks.
Additional table information: table: entertainment_awards

Answer: SELECT TYPE FROM artwork GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the year in which there are more than one festivals.
Additional table information: table: entertainment_awards

Answer: SELECT YEAR FROM festival_detail GROUP BY YEAR HAVING COUNT(*) > 1


Question:
List the name of artworks that are not nominated.
Additional table information: table: entertainment_awards

Answer: SELECT Name FROM Artwork WHERE NOT Artwork_ID IN (SELECT Artwork_ID FROM nomination)


Question:
Show the number of audience in year 2008 or 2010.
Additional table information: table: entertainment_awards

Answer: SELECT Num_of_Audience FROM festival_detail WHERE YEAR = 2008 OR YEAR = 2010


Question:
What are the total number of the audiences who visited any of the festivals?
Additional table information: table: entertainment_awards

Answer: SELECT SUM(Num_of_Audience) FROM festival_detail


Question:
In which year are there festivals both inside the 'United States' and outside the 'United States'?
Additional table information: table: entertainment_awards

Answer: SELECT YEAR FROM festival_detail WHERE LOCATION = 'United States' INTERSECT SELECT YEAR FROM festival_detail WHERE LOCATION <> 'United States'


Question:
How many premises are there?
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT COUNT(*) FROM premises


Question:
What are all the distinct premise types?
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT DISTINCT premises_type FROM premises


Question:
Find the types and details for all premises and order by the premise type.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT premises_type, premise_details FROM premises ORDER BY premises_type NULLS FIRST


Question:
Show each premise type and the number of premises in that type.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT premises_type, COUNT(*) FROM premises GROUP BY premises_type


Question:
Show all distinct product categories along with the number of mailshots in each category.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT product_category, COUNT(*) FROM mailshot_campaigns GROUP BY product_category


Question:
Show the name and phone of the customer without any mailshot.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT customer_name, customer_phone FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM mailshot_customers)


Question:
Show the name and phone for customers with a mailshot with outcome code 'No Response'.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT T1.customer_name, T1.customer_phone FROM customers AS T1 JOIN mailshot_customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.outcome_code = 'No Response'


Question:
Show the outcome code of mailshots along with the number of mailshots in each outcome code.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT outcome_code, COUNT(*) FROM mailshot_customers GROUP BY outcome_code


Question:
Show the names of customers who have at least 2 mailshots with outcome code 'Order'.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT T2.customer_name FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE outcome_code = 'Order' GROUP BY T1.customer_id HAVING COUNT(*) >= 2


Question:
Show the names of customers who have the most mailshots.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT T2.customer_name FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the name and payment method of customers who have both mailshots in 'Order' outcome and mailshots in 'No Response' outcome.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT T2.customer_name, T2.payment_method FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.outcome_code = 'Order' INTERSECT SELECT T2.customer_name, T2.payment_method FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.outcome_code = 'No Response'


Question:
Show the premise type and address type code for all customer addresses.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT T2.premises_type, T1.address_type_code FROM customer_addresses AS T1 JOIN premises AS T2 ON T1.premise_id = T2.premise_id


Question:
What are the distinct address type codes for all customer addresses?
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT DISTINCT address_type_code FROM customer_addresses


Question:
Show the shipping charge and customer id for customer orders with order status Cancelled or Paid.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT order_shipping_charges, customer_id FROM customer_orders WHERE order_status_code = 'Cancelled' OR order_status_code = 'Paid'


Question:
Show the names of customers having an order with shipping method FedEx and order status Paid.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE shipping_method_code = 'FedEx' AND order_status_code = 'Paid'


Question:
How many courses are there in total?
Additional table information: table: college_3

Answer: SELECT COUNT(*) FROM COURSE


Question:
Count the number of courses.
Additional table information: table: college_3

Answer: SELECT COUNT(*) FROM COURSE


Question:
How many courses have more than 2 credits?
Additional table information: table: college_3

Answer: SELECT COUNT(*) FROM COURSE WHERE Credits > 2


Question:
Count the number of courses with more than 2 credits.
Additional table information: table: college_3

Answer: SELECT COUNT(*) FROM COURSE WHERE Credits > 2


Question:
List all names of courses with 1 credit?
Additional table information: table: college_3

Answer: SELECT CName FROM COURSE WHERE Credits = 1


Question:
What are the names of courses with 1 credit?
Additional table information: table: college_3

Answer: SELECT CName FROM COURSE WHERE Credits = 1


Question:
Which courses are taught on days MTW?
Additional table information: table: college_3

Answer: SELECT CName FROM COURSE WHERE Days = 'MTW'


Question:
What are the course names for courses taught on MTW?
Additional table information: table: college_3

Answer: SELECT CName FROM COURSE WHERE Days = 'MTW'


Question:
What is the number of departments in Division 'AS'?
Additional table information: table: college_3

Answer: SELECT COUNT(*) FROM DEPARTMENT WHERE Division = 'AS'


Question:
How many departments are in the division AS?
Additional table information: table: college_3

Answer: SELECT COUNT(*) FROM DEPARTMENT WHERE Division = 'AS'


Question:
What are the phones of departments in Room 268?
Additional table information: table: college_3

Answer: SELECT DPhone FROM DEPARTMENT WHERE Room = 268


Question:
Give the phones for departments in room 268.
Additional table information: table: college_3

Answer: SELECT DPhone FROM DEPARTMENT WHERE Room = 268


Question:
Find the number of students that have at least one grade 'B'.
Additional table information: table: college_3

Answer: SELECT COUNT(DISTINCT StuID) FROM ENROLLED_IN WHERE Grade = 'B'


Question:
How many students have had at least one 'B' grade?
Additional table information: table: college_3

Answer: SELECT COUNT(DISTINCT StuID) FROM ENROLLED_IN WHERE Grade = 'B'


Question:
Find the max and min grade point for all letter grade.
Additional table information: table: college_3

Answer: SELECT MAX(gradepoint), MIN(gradepoint) FROM GRADECONVERSION


Question:
What are the maximum and minumum grade points?
Additional table information: table: college_3

Answer: SELECT MAX(gradepoint), MIN(gradepoint) FROM GRADECONVERSION


Question:
Find the first names of students whose first names contain letter 'a'.
Additional table information: table: college_3

Answer: SELECT DISTINCT Fname FROM STUDENT WHERE Fname LIKE '%a%'


Question:
What are the first names for students who have an 'a' in their first name?
Additional table information: table: college_3

Answer: SELECT DISTINCT Fname FROM STUDENT WHERE Fname LIKE '%a%'


Question:
Find the first names and last names of male (sex is M) faculties who live in building NEB.
Additional table information: table: college_3

Answer: SELECT Fname, Lname FROM FACULTY WHERE sex = 'M' AND Building = 'NEB'


Question:
What are the full names of faculties with sex M and who live in building NEB?
Additional table information: table: college_3

Answer: SELECT Fname, Lname FROM FACULTY WHERE sex = 'M' AND Building = 'NEB'


Question:
Find the rooms of faculties with rank professor who live in building NEB.
Additional table information: table: college_3

Answer: SELECT Room FROM FACULTY WHERE Rank = 'Professor' AND Building = 'NEB'


Question:
What are the rooms for members of the faculty who are professors and who live in building NEB?
Additional table information: table: college_3

Answer: SELECT Room FROM FACULTY WHERE Rank = 'Professor' AND Building = 'NEB'


Question:
Find the department name that is in Building 'Mergenthaler'.
Additional table information: table: college_3

Answer: SELECT DName FROM DEPARTMENT WHERE Building = 'Mergenthaler'


Question:
What is the name of the department in the Building Mergenthaler?
Additional table information: table: college_3

Answer: SELECT DName FROM DEPARTMENT WHERE Building = 'Mergenthaler'


Question:
List all information about courses sorted by credits in the ascending order.
Additional table information: table: college_3

Answer: SELECT * FROM COURSE ORDER BY Credits NULLS FIRST


Question:
What is all the information about courses, ordered by credits ascending?
Additional table information: table: college_3

Answer: SELECT * FROM COURSE ORDER BY Credits NULLS FIRST


Question:
List the course name of courses sorted by credits.
Additional table information: table: college_3

Answer: SELECT CName FROM COURSE ORDER BY Credits NULLS FIRST


Question:
What are the course names, ordered by credits?
Additional table information: table: college_3

Answer: SELECT CName FROM COURSE ORDER BY Credits NULLS FIRST


Question:
Find the first name of students in the descending order of age.
Additional table information: table: college_3

Answer: SELECT Fname FROM STUDENT ORDER BY Age DESC


Question:
What are the first names of students, ordered by age from greatest to least?
Additional table information: table: college_3

Answer: SELECT Fname FROM STUDENT ORDER BY Age DESC


Question:
Find the last name of female (sex is F) students in the descending order of age.
Additional table information: table: college_3

Answer: SELECT LName FROM STUDENT WHERE Sex = 'F' ORDER BY Age DESC


Question:
What are the last names of female students, ordered by age descending?
Additional table information: table: college_3

Answer: SELECT LName FROM STUDENT WHERE Sex = 'F' ORDER BY Age DESC


Question:
Find the last names of faculties in building Barton in alphabetic order.
Additional table information: table: college_3

Answer: SELECT Lname FROM FACULTY WHERE Building = 'Barton' ORDER BY Lname NULLS FIRST


Question:
What are the last names of faculty in building Barton, sorted by last name?
Additional table information: table: college_3

Answer: SELECT Lname FROM FACULTY WHERE Building = 'Barton' ORDER BY Lname NULLS FIRST


Question:
Find the first names of faculties of rank Professor in alphabetic order.
Additional table information: table: college_3

Answer: SELECT Fname FROM FACULTY WHERE Rank = 'Professor' ORDER BY Fname NULLS FIRST


Question:
What are the first names for all faculty professors, ordered by first name?
Additional table information: table: college_3

Answer: SELECT Fname FROM FACULTY WHERE Rank = 'Professor' ORDER BY Fname NULLS FIRST


Question:
Find the name of the department that has the biggest number of students minored in?
Additional table information: table: college_3

Answer: SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MINOR_IN AS T2 ON T1.DNO = T2.DNO GROUP BY T2.DNO ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the name of the department with the most students minoring in it?
Additional table information: table: college_3

Answer: SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MINOR_IN AS T2 ON T1.DNO = T2.DNO GROUP BY T2.DNO ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the name of the department that has no students minored in?
Additional table information: table: college_3

Answer: SELECT DName FROM DEPARTMENT EXCEPT SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MINOR_IN AS T2 ON T1.DNO = T2.DNO


Question:
What is the name of the department htat has no students minoring in it?
Additional table information: table: college_3

Answer: SELECT DName FROM DEPARTMENT EXCEPT SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MINOR_IN AS T2 ON T1.DNO = T2.DNO


Question:
Find the name of the department that has the fewest members.
Additional table information: table: college_3

Answer: SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MEMBER_OF AS T2 ON T1.DNO = T2.DNO GROUP BY T2.DNO ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
What is the name of the department with the fewest members?
Additional table information: table: college_3

Answer: SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MEMBER_OF AS T2 ON T1.DNO = T2.DNO GROUP BY T2.DNO ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
Find the rank of the faculty that the fewest faculties belong to.
Additional table information: table: college_3

Answer: SELECT Rank FROM FACULTY GROUP BY Rank ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
What is the least common faculty rank?
Additional table information: table: college_3

Answer: SELECT Rank FROM FACULTY GROUP BY Rank ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
What are the first and last names of the instructors who teach the top 3 number of courses?
Additional table information: table: college_3

Answer: SELECT T2.Fname, T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID GROUP BY T1.Instructor ORDER BY COUNT(*) DESC LIMIT 3


Question:
What are the full names of the 3 instructors who teach the most courses?
Additional table information: table: college_3

Answer: SELECT T2.Fname, T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID GROUP BY T1.Instructor ORDER BY COUNT(*) DESC LIMIT 3


Question:
Which building does the instructor who teaches the most number of courses live in?
Additional table information: table: college_3

Answer: SELECT T2.Building FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID GROUP BY T1.Instructor ORDER BY COUNT(*) DESC LIMIT 1


Question:
Give the building that the instructor who teaches the greatest number of courses lives in.
Additional table information: table: college_3

Answer: SELECT T2.Building FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID GROUP BY T1.Instructor ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the name of courses that have at least five enrollments?
Additional table information: table: college_3

Answer: SELECT T1.CName FROM COURSE AS T1 JOIN ENROLLED_IN AS T2 ON T1.CID = T2.CID GROUP BY T2.CID HAVING COUNT(*) >= 5


Question:
Give the names of the courses with at least five enrollments.
Additional table information: table: college_3

Answer: SELECT T1.CName FROM COURSE AS T1 JOIN ENROLLED_IN AS T2 ON T1.CID = T2.CID GROUP BY T2.CID HAVING COUNT(*) >= 5


Question:
Find the first name and last name of the instructor of course that has course name
Additional table information: table: college_3

Answer: SELECT T2.Fname, T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID WHERE T1.CName = 'COMPUTER LITERACY'


Question:
What is the full name of the instructor who has a course named COMPUTER LITERACY?
Additional table information: table: college_3

Answer: SELECT T2.Fname, T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID WHERE T1.CName = 'COMPUTER LITERACY'


Question:
Find the department name and room of the course INTRODUCTION TO COMPUTER SCIENCE.
Additional table information: table: college_3

Answer: SELECT T2.Dname, T2.Room FROM COURSE AS T1 JOIN DEPARTMENT AS T2 ON T1.DNO = T2.DNO WHERE T1.CName = 'INTRODUCTION TO COMPUTER SCIENCE'


Question:
What are the department name and room for the course INTRODUCTION TO COMPUTER SCIENCE?
Additional table information: table: college_3

Answer: SELECT T2.Dname, T2.Room FROM COURSE AS T1 JOIN DEPARTMENT AS T2 ON T1.DNO = T2.DNO WHERE T1.CName = 'INTRODUCTION TO COMPUTER SCIENCE'


Question:
Find the student first and last names and grade points of all enrollments.
Additional table information: table: college_3

Answer: SELECT T3.Fname, T3.LName, T2.gradepoint FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID


Question:
What are the full names and gradepoints for all enrollments?
Additional table information: table: college_3

Answer: SELECT T3.Fname, T3.LName, T2.gradepoint FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID


Question:
Find the distinct student first names of all students that have grade point at least 3.8 in one course.
Additional table information: table: college_3

Answer: SELECT DISTINCT T3.Fname FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T2.gradepoint >= 3.8


Question:
What are the distinct first names for students with a grade point of 3.8 or above in at least one course?
Additional table information: table: college_3

Answer: SELECT DISTINCT T3.Fname FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T2.gradepoint >= 3.8


Question:
Find the full names of faculties who are members of department with department number 520.
Additional table information: table: college_3

Answer: SELECT T1.Fname, T1.Lname FROM FACULTY AS T1 JOIN MEMBER_OF AS T2 ON T1.FacID = T2.FacID WHERE T2.DNO = 520


Question:
What are the full names of faculty members who are a part of department 520?
Additional table information: table: college_3

Answer: SELECT T1.Fname, T1.Lname FROM FACULTY AS T1 JOIN MEMBER_OF AS T2 ON T1.FacID = T2.FacID WHERE T2.DNO = 520


Question:
What are the first names and last names of the students that minor in the department with DNO 140.
Additional table information: table: college_3

Answer: SELECT T2.Fname, T2.Lname FROM MINOR_IN AS T1 JOIN STUDENT AS T2 ON T1.StuID = T2.StuID WHERE T1.DNO = 140


Question:
What are the full names of students minoring in department 140?
Additional table information: table: college_3

Answer: SELECT T2.Fname, T2.Lname FROM MINOR_IN AS T1 JOIN STUDENT AS T2 ON T1.StuID = T2.StuID WHERE T1.DNO = 140


Question:
Find the last names of faculties who are members of computer science department.
Additional table information: table: college_3

Answer: SELECT T2.Lname FROM DEPARTMENT AS T1 JOIN FACULTY AS T2 ON T1.DNO = T3.DNO JOIN MEMBER_OF AS T3 ON T2.FacID = T3.FacID WHERE T1.DName = 'Computer Science'


Question:
What are the last names of faculty who are part of the computer science department?
Additional table information: table: college_3

Answer: SELECT T2.Lname FROM DEPARTMENT AS T1 JOIN FACULTY AS T2 ON T1.DNO = T3.DNO JOIN MEMBER_OF AS T3 ON T2.FacID = T3.FacID WHERE T1.DName = 'Computer Science'


Question:
Find the average grade point of student whose last name is Smith.
Additional table information: table: college_3

Answer: SELECT AVG(T2.gradepoint) FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.LName = 'Smith'


Question:
What is the average gradepoint for students with the last name Smith?
Additional table information: table: college_3

Answer: SELECT AVG(T2.gradepoint) FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.LName = 'Smith'


Question:
What is the maximum and minimum grade point of students who live in NYC?
Additional table information: table: college_3

Answer: SELECT MAX(T2.gradepoint), MIN(T2.gradepoint) FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.city_code = 'NYC'


Question:
Give the maximum and minimum gradepoints for students living in NYC?
Additional table information: table: college_3

Answer: SELECT MAX(T2.gradepoint), MIN(T2.gradepoint) FROM ENROLLED_IN AS T1, GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.city_code = 'NYC'


Question:
Find the names of courses that have either 3 credits or 1 credit but 4 hours.
Additional table information: table: college_3

Answer: SELECT CName FROM COURSE WHERE Credits = 3 UNION SELECT CName FROM COURSE WHERE Credits = 1 AND Hours = 4


Question:
What are the names of courses that give either 3 credits, or 1 credit and 4 hours?
Additional table information: table: college_3

Answer: SELECT CName FROM COURSE WHERE Credits = 3 UNION SELECT CName FROM COURSE WHERE Credits = 1 AND Hours = 4


Question:
Find the names of departments that are either in division AS or in division EN and in Building NEB.
Additional table information: table: college_3

Answer: SELECT DName FROM DEPARTMENT WHERE Division = 'AS' UNION SELECT DName FROM DEPARTMENT WHERE Division = 'EN' AND Building = 'NEB'


Question:
What are the names of departments either in division AS, or in division EN and in building NEB?
Additional table information: table: college_3

Answer: SELECT DName FROM DEPARTMENT WHERE Division = 'AS' UNION SELECT DName FROM DEPARTMENT WHERE Division = 'EN' AND Building = 'NEB'


Question:
Find the first name of students not enrolled in any course.
Additional table information: table: college_3

Answer: SELECT Fname FROM STUDENT WHERE NOT StuID IN (SELECT StuID FROM ENROLLED_IN)


Question:
What are the first names of all students that are not enrolled in courses?
Additional table information: table: college_3

Answer: SELECT Fname FROM STUDENT WHERE NOT StuID IN (SELECT StuID FROM ENROLLED_IN)


Question:
What are the ids of the top three products that were purchased in the largest amount?
Additional table information: table: department_store

Answer: SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3


Question:
Give the ids of the three products purchased in the largest amounts.
Additional table information: table: department_store

Answer: SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3


Question:
What are the product id and product type of the cheapest product?
Additional table information: table: department_store

Answer: SELECT product_id, product_type_code FROM products ORDER BY product_price NULLS FIRST LIMIT 1


Question:
Give the id and product type of the product with the lowest price.
Additional table information: table: department_store

Answer: SELECT product_id, product_type_code FROM products ORDER BY product_price NULLS FIRST LIMIT 1


Question:
Find the number of different product types.
Additional table information: table: department_store

Answer: SELECT COUNT(DISTINCT product_type_code) FROM products


Question:
Count the number of distinct product types.
Additional table information: table: department_store

Answer: SELECT COUNT(DISTINCT product_type_code) FROM products


Question:
Return the address of customer 10.
Additional table information: table: department_store

Answer: SELECT T1.address_details FROM addresses AS T1 JOIN customer_addresses AS T2 ON T1.address_id = T2.address_id WHERE T2.customer_id = 10


Question:
What is the address for the customer with id 10?
Additional table information: table: department_store

Answer: SELECT T1.address_details FROM addresses AS T1 JOIN customer_addresses AS T2 ON T1.address_id = T2.address_id WHERE T2.customer_id = 10


Question:
What are the staff ids and genders of all staffs whose job title is Department Manager?
Additional table information: table: department_store

Answer: SELECT T1.staff_id, T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = 'Department Manager'


Question:
Return the staff ids and genders for any staff with the title Department Manager.
Additional table information: table: department_store

Answer: SELECT T1.staff_id, T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = 'Department Manager'


Question:
For each payment method, return how many customers use it.
Additional table information: table: department_store

Answer: SELECT payment_method_code, COUNT(*) FROM customers GROUP BY payment_method_code


Question:
How many customers use each payment method?
Additional table information: table: department_store

Answer: SELECT payment_method_code, COUNT(*) FROM customers GROUP BY payment_method_code


Question:
What is the id of the product that was ordered the most often?
Additional table information: table: department_store

Answer: SELECT product_id FROM order_items GROUP BY product_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Give the product id for the product that was ordered most frequently.
Additional table information: table: department_store

Answer: SELECT product_id FROM order_items GROUP BY product_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the name, phone number and email address of the customer who made the largest number of orders?
Additional table information: table: department_store

Answer: SELECT T1.customer_name, T1.customer_phone, T1.customer_email FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Return the name, phone number and email address for the customer with the most orders.
Additional table information: table: department_store

Answer: SELECT T1.customer_name, T1.customer_phone, T1.customer_email FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the average price for each type of product?
Additional table information: table: department_store

Answer: SELECT product_type_code, AVG(product_price) FROM products GROUP BY product_type_code


Question:
Return the average price for each product type.
Additional table information: table: department_store

Answer: SELECT product_type_code, AVG(product_price) FROM products GROUP BY product_type_code


Question:
How many department stores does the store chain South have?
Additional table information: table: department_store

Answer: SELECT COUNT(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id = T2.dept_store_chain_id WHERE T2.dept_store_chain_name = 'South'


Question:
Count the number of stores the chain South has.
Additional table information: table: department_store

Answer: SELECT COUNT(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id = T2.dept_store_chain_id WHERE T2.dept_store_chain_name = 'South'


Question:
What is the name and job title of the staff who was assigned the latest?
Additional table information: table: department_store

Answer: SELECT T1.staff_name, T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1


Question:
Return the name and job title of the staff with the latest date assigned.
Additional table information: table: department_store

Answer: SELECT T1.staff_name, T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1


Question:
Give me the product type, name and price for all the products supplied by supplier id 3.
Additional table information: table: department_store

Answer: SELECT T2.product_type_code, T2.product_name, T2.product_price FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 3


Question:
Return the product type, name, and price for products supplied by supplier 3.
Additional table information: table: department_store

Answer: SELECT T2.product_type_code, T2.product_name, T2.product_price FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 3


Question:
Return the distinct name of customers whose order status is Pending, in the order of customer id.
Additional table information: table: department_store

Answer: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Pending' ORDER BY T2.customer_id NULLS FIRST


Question:
What are the distinct names of customers with an order status of Pending, sorted by customer id?
Additional table information: table: department_store

Answer: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Pending' ORDER BY T2.customer_id NULLS FIRST


Question:
Find the name and address of the customers who have both New and Pending orders.
Additional table information: table: department_store

Answer: SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'New' INTERSECT SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Pending'


Question:
What are the names and addressed of customers who have both New and Pending orders?
Additional table information: table: department_store

Answer: SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'New' INTERSECT SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Pending'


Question:
Return ids of all the products that are supplied by supplier id 2 and are more expensive than the average price of all products.
Additional table information: table: department_store

Answer: SELECT T1.product_id FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 2 AND T2.product_price > (SELECT AVG(product_price) FROM products)


Question:
What are the ids of products from the supplier with id 2, which are more expensive than the average price across all products?
Additional table information: table: department_store

Answer: SELECT T1.product_id FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 2 AND T2.product_price > (SELECT AVG(product_price) FROM products)


Question:
What is the id and name of the department store that has both marketing and managing department?
Additional table information: table: department_store

Answer: SELECT T2.dept_store_id, T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = 'marketing' INTERSECT SELECT T2.dept_store_id, T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = 'managing'


Question:
What are the ids and names of department stores with both marketing and managing departments?
Additional table information: table: department_store

Answer: SELECT T2.dept_store_id, T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = 'marketing' INTERSECT SELECT T2.dept_store_id, T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = 'managing'


Question:
What are the ids of the two department store chains with the largest number of department stores?
Additional table information: table: department_store

Answer: SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY COUNT(*) DESC LIMIT 2


Question:
Return the ids of the two department store chains with the most department stores.
Additional table information: table: department_store

Answer: SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY COUNT(*) DESC LIMIT 2


Question:
What is the id of the department with the least number of staff?
Additional table information: table: department_store

Answer: SELECT department_id FROM staff_department_assignments GROUP BY department_id ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
Return the id of the department with the fewest staff assignments.
Additional table information: table: department_store

Answer: SELECT department_id FROM staff_department_assignments GROUP BY department_id ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
For each product type, return the maximum and minimum price.
Additional table information: table: department_store

Answer: SELECT product_type_code, MAX(product_price), MIN(product_price) FROM products GROUP BY product_type_code


Question:
What are the maximum and minimum product prices for each product type?
Additional table information: table: department_store

Answer: SELECT product_type_code, MAX(product_price), MIN(product_price) FROM products GROUP BY product_type_code


Question:
Find the product type whose average price is higher than the average price of all products.
Additional table information: table: department_store

Answer: SELECT product_type_code FROM products GROUP BY product_type_code HAVING AVG(product_price) > (SELECT AVG(product_price) FROM products)


Question:
What is the code of the product type with an average price higher than the average price of all products?
Additional table information: table: department_store

Answer: SELECT product_type_code FROM products GROUP BY product_type_code HAVING AVG(product_price) > (SELECT AVG(product_price) FROM products)


Question:
Find the id and name of the staff who has been assigned for the shortest period.
Additional table information: table: department_store

Answer: SELECT T1.staff_id, T1.staff_name FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY date_assigned_to - date_assigned_from NULLS FIRST LIMIT 1


Question:
What is the id and name of the staff who has been assigned for the least amount of time?
Additional table information: table: department_store

Answer: SELECT T1.staff_id, T1.staff_name FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY date_assigned_to - date_assigned_from NULLS FIRST LIMIT 1


Question:
Return the names and ids of all products whose price is between 600 and 700.
Additional table information: table: department_store

Answer: SELECT product_name, product_id FROM products WHERE product_price BETWEEN 600 AND 700


Question:
What are the names and ids of products costing between 600 and 700?
Additional table information: table: department_store

Answer: SELECT product_name, product_id FROM products WHERE product_price BETWEEN 600 AND 700


Question:
Find the ids of all distinct customers who made order after some orders that were Cancelled.
Additional table information: table: department_store

Answer: SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT MIN(order_date) FROM Customer_Orders WHERE order_status_code = 'Cancelled')


Question:
What are the distinct ids of customers who made an order after any order that was Cancelled?
Additional table information: table: department_store

Answer: SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT MIN(order_date) FROM Customer_Orders WHERE order_status_code = 'Cancelled')


Question:
What is id of the staff who had a Staff Department Assignment earlier than any Clerical Staff?
Additional table information: table: department_store

Answer: SELECT staff_id FROM Staff_Department_Assignments WHERE date_assigned_to < (SELECT MAX(date_assigned_to) FROM Staff_Department_Assignments WHERE job_title_code = 'Clerical Staff')


Question:
Return the id of the staff whose Staff Department Assignment was earlier than that of any Clerical Staff.
Additional table information: table: department_store

Answer: SELECT staff_id FROM Staff_Department_Assignments WHERE date_assigned_to < (SELECT MAX(date_assigned_to) FROM Staff_Department_Assignments WHERE job_title_code = 'Clerical Staff')


Question:
What are the names and ids of customers whose address contains TN?
Additional table information: table: department_store

Answer: SELECT customer_name, customer_id FROM customers WHERE customer_address LIKE '%TN%'


Question:
Return the names and ids of customers who have TN in their address.
Additional table information: table: department_store

Answer: SELECT customer_name, customer_id FROM customers WHERE customer_address LIKE '%TN%'


Question:
Return the name and gender of the staff who was assigned in 2016.
Additional table information: table: department_store

Answer: SELECT T1.staff_name, T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.date_assigned_from LIKE '2016%'


Question:
What are the names and genders of staff who were assigned in 2016?
Additional table information: table: department_store

Answer: SELECT T1.staff_name, T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.date_assigned_from LIKE '2016%'


Question:
List the name of staff who has been assigned multiple jobs.
Additional table information: table: department_store

Answer: SELECT T1.staff_name FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id GROUP BY T2.staff_id HAVING COUNT(*) > 1


Question:
What are the names of staff who have been assigned multiple jobs?
Additional table information: table: department_store

Answer: SELECT T1.staff_name FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id GROUP BY T2.staff_id HAVING COUNT(*) > 1


Question:
List the name and phone number of all suppliers in the alphabetical order of their addresses.
Additional table information: table: department_store

Answer: SELECT T1.supplier_name, T1.supplier_phone FROM Suppliers AS T1 JOIN supplier_addresses AS T2 ON T1.supplier_id = T2.supplier_id JOIN addresses AS T3 ON T2.address_id = T3.address_id ORDER BY T3.address_details NULLS FIRST


Question:
What are the names and phone numbers for all suppliers, sorted in alphabetical order of their addressed?
Additional table information: table: department_store

Answer: SELECT T1.supplier_name, T1.supplier_phone FROM Suppliers AS T1 JOIN supplier_addresses AS T2 ON T1.supplier_id = T2.supplier_id JOIN addresses AS T3 ON T2.address_id = T3.address_id ORDER BY T3.address_details NULLS FIRST


Question:
What are the phone numbers of all customers and suppliers.
Additional table information: table: department_store

Answer: SELECT customer_phone FROM customers UNION SELECT supplier_phone FROM suppliers


Question:
Return the phone numbers for all customers and suppliers.
Additional table information: table: department_store

Answer: SELECT customer_phone FROM customers UNION SELECT supplier_phone FROM suppliers


Question:
Return the ids of all products that were ordered more than three times or supplied more than 80000.
Additional table information: table: department_store

Answer: SELECT product_id FROM Order_Items GROUP BY product_id HAVING COUNT(*) > 3 UNION SELECT product_id FROM Product_Suppliers GROUP BY product_id HAVING SUM(total_amount_purchased) > 80000


Question:
What are the ids of all products that were either ordered more than 3 times or have a cumulative amount purchased of above 80000?
Additional table information: table: department_store

Answer: SELECT product_id FROM Order_Items GROUP BY product_id HAVING COUNT(*) > 3 UNION SELECT product_id FROM Product_Suppliers GROUP BY product_id HAVING SUM(total_amount_purchased) > 80000


Question:
What are id and name of the products whose price is lower than 600 or higher than 900?
Additional table information: table: department_store

Answer: SELECT product_id, product_name FROM products WHERE product_price < 600 OR product_price > 900


Question:
Give the ids and names of products with price lower than 600 or higher than 900.
Additional table information: table: department_store

Answer: SELECT product_id, product_name FROM products WHERE product_price < 600 OR product_price > 900


Question:
Find the id of suppliers whose average amount purchased for each product is above 50000 or below 30000.
Additional table information: table: department_store

Answer: SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING AVG(total_amount_purchased) > 50000 OR AVG(total_amount_purchased) < 30000


Question:
What are the ids of suppliers which have an average amount purchased of above 50000 or below 30000?
Additional table information: table: department_store

Answer: SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING AVG(total_amount_purchased) > 50000 OR AVG(total_amount_purchased) < 30000


Question:
What are the average amount purchased and value purchased for the supplier who supplies the most products.
Additional table information: table: department_store

Answer: SELECT AVG(total_amount_purchased), AVG(total_value_purchased) FROM Product_Suppliers WHERE supplier_id = (SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id ORDER BY COUNT(*) DESC LIMIT 1)


Question:
Return the average total amount purchased and total value purchased for the supplier who supplies the greatest number of products.
Additional table information: table: department_store

Answer: SELECT AVG(total_amount_purchased), AVG(total_value_purchased) FROM Product_Suppliers WHERE supplier_id = (SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id ORDER BY COUNT(*) DESC LIMIT 1)


Question:
What is the largest and smallest customer codes?
Additional table information: table: department_store

Answer: SELECT MAX(customer_code), MIN(customer_code) FROM Customers


Question:
Return the maximum and minimum customer codes.
Additional table information: table: department_store

Answer: SELECT MAX(customer_code), MIN(customer_code) FROM Customers


Question:
List the names of all the distinct customers who bought a keyboard.
Additional table information: table: department_store

Answer: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id JOIN products AS T4 ON T3.product_id = T4.product_id WHERE T4.product_name = 'keyboard'


Question:
What are the distinct names of customers who have purchased a keyboard?
Additional table information: table: department_store

Answer: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id JOIN products AS T4 ON T3.product_id = T4.product_id WHERE T4.product_name = 'keyboard'