training_input
stringlengths
118
1.06k
###context:CREATE TABLE organisation_Types (organisation_type VARCHAR, organisation_type_description VARCHAR); CREATE TABLE Grants (grant_id VARCHAR, organisation_id VARCHAR, grant_amount VARCHAR); CREATE TABLE Organisations (organisation_id VARCHAR, organisation_type VARCHAR); CREATE TABLE documents (sent_date VARCHAR, grant_id VARCHAR) ###human: Find out the send dates of the documents with the grant amount of more than 5000 were granted by organisation type described ###assistant: SELECT T1.sent_date FROM documents AS T1 JOIN Grants AS T2 ON T1.grant_id = T2.grant_id JOIN Organisations AS T3 ON T2.organisation_id = T3.organisation_id JOIN organisation_Types AS T4 ON T3.organisation_type = T4.organisation_type WHERE T2.grant_amount > 5000 AND T4.organisation_type_description = 'Research'
###context:CREATE TABLE Documents (response_received_date VARCHAR, document_type_code VARCHAR, grant_id VARCHAR); CREATE TABLE Document_Types (document_type_code VARCHAR, document_description VARCHAR); CREATE TABLE Grants (grant_id VARCHAR, grant_amount VARCHAR) ###human: What are the response received dates for the documents described as 'Regular' or granted with more than 100? ###assistant: SELECT T1.response_received_date FROM Documents AS T1 JOIN Document_Types AS T2 ON T1.document_type_code = T2.document_type_code JOIN Grants AS T3 ON T1.grant_id = T3.grant_id WHERE T2.document_description = 'Regular' OR T3.grant_amount > 100
###context:CREATE TABLE Projects (project_details VARCHAR, project_id VARCHAR, role_code VARCHAR); CREATE TABLE Project_Staff (project_details VARCHAR, project_id VARCHAR, role_code VARCHAR) ###human: List the project details of the projects which did not hire any staff for a researcher role. ###assistant: SELECT project_details FROM Projects WHERE NOT project_id IN (SELECT project_id FROM Project_Staff WHERE role_code = 'researcher')
###context:CREATE TABLE Projects (project_id VARCHAR, project_details VARCHAR); CREATE TABLE Project_outcomes (project_id VARCHAR); CREATE TABLE Tasks (task_details VARCHAR, task_id VARCHAR, project_id VARCHAR) ###human: What are the task details, task id and project id for the projects which are detailed as 'omnis' or have more than 2 outcomes? ###assistant: SELECT T1.task_details, T1.task_id, T2.project_id FROM Tasks AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id WHERE T2.project_details = 'omnis' UNION SELECT T1.task_details, T1.task_id, T2.project_id FROM Tasks AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id JOIN Project_outcomes AS T3 ON T2.project_id = T3.project_id GROUP BY T2.project_id HAVING COUNT(*) > 2
###context:CREATE TABLE Project_Staff (date_from VARCHAR, date_to VARCHAR, role_code VARCHAR) ###human: When do all the researcher role staff start to work, and when do they stop working? ###assistant: SELECT date_from, date_to FROM Project_Staff WHERE role_code = 'researcher'
###context:CREATE TABLE Project_Staff (role_code VARCHAR) ###human: How many kinds of roles are there for the staff? ###assistant: SELECT COUNT(DISTINCT role_code) FROM Project_Staff
###context:CREATE TABLE Grants (organisation_id VARCHAR, grant_amount INTEGER) ###human: What is the total amount of grants given by each organisations? Also list the organisation id. ###assistant: SELECT SUM(grant_amount), organisation_id FROM Grants GROUP BY organisation_id
###context:CREATE TABLE Research_outcomes (outcome_code VARCHAR, outcome_description VARCHAR); CREATE TABLE Project_outcomes (project_id VARCHAR, outcome_code VARCHAR); CREATE TABLE Projects (project_details VARCHAR, project_id VARCHAR) ###human: List the project details of the projects with the research outcome described with the substring 'Published'. ###assistant: SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id JOIN Research_outcomes AS T3 ON T2.outcome_code = T3.outcome_code WHERE T3.outcome_description LIKE '%Published%'
###context:CREATE TABLE Project_Staff (project_id VARCHAR); CREATE TABLE Projects (project_id VARCHAR) ###human: How many staff does each project has? List the project id and the number in an ascending order. ###assistant: SELECT T1.project_id, COUNT(*) FROM Project_Staff AS T1 JOIN Projects AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id ORDER BY COUNT(*)
###context:CREATE TABLE Staff_Roles (role_description VARCHAR, role_code VARCHAR) ###human: What is the complete description of the researcher role. ###assistant: SELECT role_description FROM Staff_Roles WHERE role_code = 'researcher'
###context:CREATE TABLE Project_Staff (date_from VARCHAR) ###human: When did the first staff for the projects started working? ###assistant: SELECT date_from FROM Project_Staff ORDER BY date_from LIMIT 1
###context:CREATE TABLE Project_outcomes (project_id VARCHAR); CREATE TABLE Projects (project_details VARCHAR, project_id VARCHAR) ###human: Which project made the most number of outcomes? List the project details and the project id. ###assistant: SELECT T1.project_details, T1.project_id FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id GROUP BY T1.project_id ORDER BY COUNT(*) DESC LIMIT 1
###context:CREATE TABLE Project_outcomes (project_details VARCHAR, project_id VARCHAR); CREATE TABLE Projects (project_details VARCHAR, project_id VARCHAR) ###human: Which projects have no outcome? List the project details. ###assistant: SELECT project_details FROM Projects WHERE NOT project_id IN (SELECT project_id FROM Project_outcomes)
###context:CREATE TABLE Organisations (organisation_id VARCHAR, organisation_type VARCHAR, organisation_details VARCHAR); CREATE TABLE Research_Staff (employer_organisation_id VARCHAR) ###human: Which organisation hired the most number of research staff? List the organisation id, type and detail. ###assistant: SELECT T1.organisation_id, T1.organisation_type, T1.organisation_details FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id = T2.employer_organisation_id GROUP BY T1.organisation_id ORDER BY COUNT(*) DESC LIMIT 1
###context:CREATE TABLE Project_outcomes (project_id VARCHAR); CREATE TABLE Project_Staff (staff_id VARCHAR, role_code VARCHAR, project_id VARCHAR); CREATE TABLE Staff_Roles (role_description VARCHAR, role_code VARCHAR) ###human: Show the role description and the id of the project staff involved in most number of project outcomes? ###assistant: SELECT T1.role_description, T2.staff_id FROM Staff_Roles AS T1 JOIN Project_Staff AS T2 ON T1.role_code = T2.role_code JOIN Project_outcomes AS T3 ON T2.project_id = T3.project_id GROUP BY T2.staff_id ORDER BY COUNT(*) DESC LIMIT 1
###context:CREATE TABLE Document_Types (document_type_code VARCHAR, document_description VARCHAR) ###human: Which document type is described with the prefix 'Initial'? ###assistant: SELECT document_type_code FROM Document_Types WHERE document_description LIKE 'Initial%'
###context:CREATE TABLE Grants (grant_start_date VARCHAR, grant_id VARCHAR); CREATE TABLE Document_Types (document_type_code VARCHAR, document_description VARCHAR); CREATE TABLE Documents (grant_id VARCHAR, document_type_code VARCHAR) ###human: For grants with both documents described as 'Regular' and documents described as 'Initial Application', list its start date. ###assistant: SELECT T1.grant_start_date FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id = T2.grant_id JOIN Document_Types AS T3 ON T2.document_type_code = T3.document_type_code WHERE T3.document_description = 'Regular' INTERSECT SELECT T1.grant_start_date FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id = T2.grant_id JOIN Document_Types AS T3 ON T2.document_type_code = T3.document_type_code WHERE T3.document_description = 'Initial Application'
###context:CREATE TABLE Documents (grant_id VARCHAR) ###human: How many documents can one grant have at most? List the grant id and number. ###assistant: SELECT grant_id, COUNT(*) FROM Documents GROUP BY grant_id ORDER BY COUNT(*) DESC LIMIT 1
###context:CREATE TABLE Organisations (organisation_type VARCHAR, organisation_details VARCHAR); CREATE TABLE organisation_Types (organisation_type_description VARCHAR, organisation_type VARCHAR) ###human: Find the organisation type description of the organisation detailed as 'quo'. ###assistant: SELECT T1.organisation_type_description FROM organisation_Types AS T1 JOIN Organisations AS T2 ON T1.organisation_type = T2.organisation_type WHERE T2.organisation_details = 'quo'
###context:CREATE TABLE organisation_Types (organisation_type VARCHAR, organisation_type_description VARCHAR); CREATE TABLE Organisations (organisation_type VARCHAR) ###human: What are all the details of the organisations described as 'Sponsor'? Sort the result in an ascending order. ###assistant: SELECT organisation_details FROM Organisations AS T1 JOIN organisation_Types AS T2 ON T1.organisation_type = T2.organisation_type WHERE T2.organisation_type_description = 'Sponsor' ORDER BY organisation_details
###context:CREATE TABLE Project_outcomes (outcome_code VARCHAR) ###human: How many Patent outcomes are generated from all the projects? ###assistant: SELECT COUNT(*) FROM Project_outcomes WHERE outcome_code = 'Patent'
###context:CREATE TABLE Project_Staff (role_code VARCHAR, date_from VARCHAR) ###human: How many project staff worked as leaders or started working before '1989-04-24 23:51:54'? ###assistant: SELECT COUNT(*) FROM Project_Staff WHERE role_code = 'leader' OR date_from < '1989-04-24 23:51:54'
###context:CREATE TABLE Project_Staff (date_to VARCHAR) ###human: What is the last date of the staff leaving the projects? ###assistant: SELECT date_to FROM Project_Staff ORDER BY date_to DESC LIMIT 1
###context:CREATE TABLE Project_outcomes (outcome_code VARCHAR, project_id VARCHAR); CREATE TABLE Research_outcomes (outcome_description VARCHAR, outcome_code VARCHAR); CREATE TABLE Projects (project_id VARCHAR, project_details VARCHAR) ###human: What are the result description of the project whose detail is 'sint'? ###assistant: SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code = T2.outcome_code JOIN Projects AS T3 ON T2.project_id = T3.project_id WHERE T3.project_details = 'sint'
###context:CREATE TABLE Project_outcomes (project_id VARCHAR); CREATE TABLE Projects (organisation_id VARCHAR, project_id VARCHAR) ###human: List the organisation id with the maximum outcome count, and the count. ###assistant: SELECT T1.organisation_id, COUNT(*) FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id GROUP BY T1.organisation_id ORDER BY COUNT(*) DESC LIMIT 1
###context:CREATE TABLE Projects (project_details VARCHAR, organisation_id VARCHAR) ###human: List the project details of the projects launched by the organisation ###assistant: SELECT project_details FROM Projects WHERE organisation_id IN (SELECT organisation_id FROM Projects GROUP BY organisation_id ORDER BY COUNT(*) DESC LIMIT 1)
###context:CREATE TABLE Research_Staff (staff_details VARCHAR) ###human: List the research staff details, and order in ascending order. ###assistant: SELECT staff_details FROM Research_Staff ORDER BY staff_details
###context:CREATE TABLE Tasks (Id VARCHAR) ###human: How many tasks are there in total? ###assistant: SELECT COUNT(*) FROM Tasks
###context:CREATE TABLE Projects (project_details VARCHAR, project_id VARCHAR); CREATE TABLE Tasks (project_id VARCHAR) ###human: How many tasks does each project have? List the task count and the project detail. ###assistant: 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
###context:CREATE TABLE Project_Staff (role_code VARCHAR, date_from VARCHAR, date_to VARCHAR) ###human: What are the staff roles of the staff who ###assistant: SELECT role_code FROM Project_Staff WHERE date_from > '2003-04-19 15:06:20' AND date_to < '2016-03-15 00:33:18'
###context:CREATE TABLE Research_outcomes (outcome_description VARCHAR, outcome_code VARCHAR); CREATE TABLE Project_outcomes (outcome_code VARCHAR) ###human: What are the descriptions of all the project outcomes? ###assistant: SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code = T2.outcome_code
###context:CREATE TABLE Project_Staff (role_code VARCHAR) ###human: Which role is most common for the staff? ###assistant: SELECT role_code FROM Project_Staff GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1
###context:CREATE TABLE PersonFriend (friend VARCHAR, name VARCHAR); CREATE TABLE Person (name VARCHAR) ###human: How many friends does Dan have? ###assistant: SELECT COUNT(T2.friend) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Dan'
###context:CREATE TABLE Person (gender VARCHAR) ###human: How many females does this network has? ###assistant: SELECT COUNT(*) FROM Person WHERE gender = 'female'
###context:CREATE TABLE Person (age INTEGER) ###human: What is the average age for all person? ###assistant: SELECT AVG(age) FROM Person
###context:CREATE TABLE Person (city VARCHAR) ###human: How many different cities are they from? ###assistant: SELECT COUNT(DISTINCT city) FROM Person
###context:CREATE TABLE Person (job VARCHAR) ###human: How many type of jobs do they have? ###assistant: SELECT COUNT(DISTINCT job) FROM Person
###context:CREATE TABLE Person (name VARCHAR, age INTEGER); CREATE TABLE person (name VARCHAR, age INTEGER) ###human: Who is the oldest person? ###assistant: SELECT name FROM Person WHERE age = (SELECT MAX(age) FROM person)
###context:CREATE TABLE person (name VARCHAR, job VARCHAR, age INTEGER); CREATE TABLE Person (name VARCHAR, job VARCHAR, age INTEGER) ###human: Who is the oldest person whose job is student? ###assistant: SELECT name FROM Person WHERE job = 'student' AND age = (SELECT MAX(age) FROM person WHERE job = 'student')
###context:CREATE TABLE Person (name VARCHAR, gender VARCHAR, age INTEGER); CREATE TABLE person (name VARCHAR, gender VARCHAR, age INTEGER) ###human: Who is the youngest male? ###assistant: SELECT name FROM Person WHERE gender = 'male' AND age = (SELECT MIN(age) FROM person WHERE gender = 'male')
###context:CREATE TABLE Person (age VARCHAR, job VARCHAR, name VARCHAR) ###human: How old is the doctor named Zach? ###assistant: SELECT age FROM Person WHERE job = 'doctor' AND name = 'Zach'
###context:CREATE TABLE Person (name VARCHAR, age INTEGER) ###human: Who is the person whose age is below 30? ###assistant: SELECT name FROM Person WHERE age < 30
###context:CREATE TABLE Person (age VARCHAR, job VARCHAR) ###human: How many people whose age is greater 30 and job is engineer? ###assistant: SELECT COUNT(*) FROM Person WHERE age > 30 AND job = 'engineer'
###context:CREATE TABLE Person (gender VARCHAR, age INTEGER) ###human: What is the average age for each gender? ###assistant: SELECT AVG(age), gender FROM Person GROUP BY gender
###context:CREATE TABLE Person (job VARCHAR, age INTEGER) ###human: What is average age for different job title? ###assistant: SELECT AVG(age), job FROM Person GROUP BY job
###context:CREATE TABLE Person (job VARCHAR, age INTEGER, gender VARCHAR) ###human: What is average age of male for different job title? ###assistant: SELECT AVG(age), job FROM Person WHERE gender = 'male' GROUP BY job
###context:CREATE TABLE Person (job VARCHAR, age INTEGER) ###human: What is minimum age for different job title? ###assistant: SELECT MIN(age), job FROM Person GROUP BY job
###context:CREATE TABLE Person (gender VARCHAR, age INTEGER) ###human: Find the number of people who is under 40 for each gender. ###assistant: SELECT COUNT(*), gender FROM Person WHERE age < 40 GROUP BY gender
###context:CREATE TABLE Person (name VARCHAR, age INTEGER, job VARCHAR); CREATE TABLE person (name VARCHAR, age INTEGER, job VARCHAR) ###human: Find the name of people whose age is greater than any engineer sorted by their age. ###assistant: SELECT name FROM Person WHERE age > (SELECT MIN(age) FROM person WHERE job = 'engineer') ORDER BY age
###context:CREATE TABLE Person (age INTEGER, job VARCHAR); CREATE TABLE person (age INTEGER, job VARCHAR) ###human: Find the number of people whose age is greater than all engineers. ###assistant: SELECT COUNT(*) FROM Person WHERE age > (SELECT MAX(age) FROM person WHERE job = 'engineer')
###context:CREATE TABLE Person (name VARCHAR, job VARCHAR) ###human: list the name, job title of all people ordered by their names. ###assistant: SELECT name, job FROM Person ORDER BY name
###context:CREATE TABLE Person (name VARCHAR, age VARCHAR) ###human: Find the names of all person sorted in the descending order using age. ###assistant: SELECT name FROM Person ORDER BY age DESC
###context:CREATE TABLE Person (name VARCHAR, gender VARCHAR, age VARCHAR) ###human: Find the name and age of all males in order of their age. ###assistant: SELECT name FROM Person WHERE gender = 'male' ORDER BY age
###context:CREATE TABLE Person (name VARCHAR, age VARCHAR); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR) ###human: Find the name and age of the person who is a friend of both Dan and Alice. ###assistant: 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'
###context:CREATE TABLE Person (name VARCHAR, age VARCHAR); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR) ###human: Find the name and age of the person who is a friend of Dan or Alice. ###assistant: 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'
###context:CREATE TABLE Person (name VARCHAR, age INTEGER); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR); CREATE TABLE Person (name VARCHAR) ###human: Find the name of the person who has friends with age above 40 and under age 30? ###assistant: 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)
###context:CREATE TABLE Person (name VARCHAR, age INTEGER); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR); CREATE TABLE Person (name VARCHAR) ###human: Find the name of the person who has friends with age above 40 but not under age 30? ###assistant: 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)
###context:CREATE TABLE Person (name VARCHAR, job VARCHAR); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR); CREATE TABLE person (name VARCHAR) ###human: Find the name of the person who has no student friends. ###assistant: 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'
###context:CREATE TABLE PersonFriend (name VARCHAR) ###human: Find the person who has exactly one friend. ###assistant: SELECT name FROM PersonFriend GROUP BY name HAVING COUNT(*) = 1
###context:CREATE TABLE PersonFriend (friend VARCHAR, name VARCHAR); CREATE TABLE Person (name VARCHAR) ###human: Who are the friends of Bob? ###assistant: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T1.name = 'Bob'
###context:CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR); CREATE TABLE Person (name VARCHAR) ###human: Find the name of persons who are friends with Bob. ###assistant: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Bob'
###context:CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR); CREATE TABLE Person (name VARCHAR, gender VARCHAR) ###human: Find the names of females who are friends with Zach ###assistant: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Zach' AND T1.gender = 'female'
###context:CREATE TABLE PersonFriend (friend VARCHAR, name VARCHAR); CREATE TABLE Person (name VARCHAR, gender VARCHAR) ###human: Find the female friends of Alice. ###assistant: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T2.name = 'Alice' AND T1.gender = 'female'
###context:CREATE TABLE PersonFriend (friend VARCHAR, name VARCHAR); CREATE TABLE Person (name VARCHAR, job VARCHAR, gender VARCHAR) ###human: Find the male friend of Alice whose job is a doctor? ###assistant: 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'
###context:CREATE TABLE Person (name VARCHAR, city VARCHAR); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR) ###human: Who has a friend that is from new york city? ###assistant: SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.friend WHERE T1.city = 'new york city'
###context:CREATE TABLE person (age INTEGER); CREATE TABLE Person (name VARCHAR, age INTEGER); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR) ###human: Who has friends that are younger than the average age? ###assistant: 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)
###context:CREATE TABLE person (age INTEGER); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR); CREATE TABLE Person (age INTEGER, name VARCHAR) ###human: Who has friends that are older than the average age? Print their friends and their ages as well ###assistant: 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)
###context:CREATE TABLE PersonFriend (friend VARCHAR, name VARCHAR, YEAR INTEGER) ###human: Who is the friend of Zach with longest year relationship? ###assistant: SELECT friend FROM PersonFriend WHERE name = 'Zach' AND YEAR = (SELECT MAX(YEAR) FROM PersonFriend WHERE name = 'Zach')
###context:CREATE TABLE PersonFriend (friend VARCHAR, name VARCHAR, year VARCHAR); CREATE TABLE PersonFriend (YEAR INTEGER, name VARCHAR); CREATE TABLE Person (age VARCHAR, name VARCHAR) ###human: What is the age of the friend of Zach with longest year relationship? ###assistant: 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')
###context:CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR, YEAR INTEGER) ###human: Find the name of persons who are friends with Alice for the shortest years. ###assistant: SELECT name FROM PersonFriend WHERE friend = 'Alice' AND YEAR = (SELECT MIN(YEAR) FROM PersonFriend WHERE friend = 'Alice')
###context:CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR, year VARCHAR); CREATE TABLE Person (name VARCHAR, age VARCHAR, job VARCHAR); CREATE TABLE PersonFriend (YEAR INTEGER, friend VARCHAR) ###human: Find the name, age, and job title of persons who are friends with Alice for the longest years. ###assistant: 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')
###context:CREATE TABLE PersonFriend (name VARCHAR); CREATE TABLE person (name VARCHAR) ###human: Who is the person that has no friend? ###assistant: SELECT name FROM person EXCEPT SELECT name FROM PersonFriend
###context:CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR); CREATE TABLE Person (age INTEGER, name VARCHAR) ###human: Which person whose friends have the oldest average age? ###assistant: 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
###context:CREATE TABLE person (name VARCHAR, friend VARCHAR, city VARCHAR); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR, city VARCHAR) ###human: What is the total number of people who has no friend living in the city of Austin. ###assistant: SELECT COUNT(DISTINCT name) FROM PersonFriend WHERE NOT friend IN (SELECT name FROM person WHERE city = 'Austin')
###context:CREATE TABLE PersonFriend (name VARCHAR); CREATE TABLE PersonFriend (name VARCHAR, friend VARCHAR); CREATE TABLE Person (name VARCHAR) ###human: Find Alice's friends of friends. ###assistant: 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'
###context:CREATE TABLE member (Id VARCHAR) ###human: How many members are there? ###assistant: SELECT COUNT(*) FROM member
###context:CREATE TABLE member (Name VARCHAR) ###human: List the names of members in ascending alphabetical order. ###assistant: SELECT Name FROM member ORDER BY Name
###context:CREATE TABLE member (Name VARCHAR, Country VARCHAR) ###human: What are the names and countries of members? ###assistant: SELECT Name, Country FROM member
###context:CREATE TABLE member (Name VARCHAR, Country VARCHAR) ###human: Show the names of members whose country is "United States" or "Canada". ###assistant: SELECT Name FROM member WHERE Country = "United States" OR Country = "Canada"
###context:CREATE TABLE member (Country VARCHAR) ###human: Show the different countries and the number of members from each. ###assistant: SELECT Country, COUNT(*) FROM member GROUP BY Country
###context:CREATE TABLE member (Country VARCHAR) ###human: Show the most common country across members. ###assistant: SELECT Country FROM member GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1
###context:CREATE TABLE member (Country VARCHAR) ###human: Which countries have more than two members? ###assistant: SELECT Country FROM member GROUP BY Country HAVING COUNT(*) > 2
###context:CREATE TABLE college (Leader_Name VARCHAR, College_Location VARCHAR) ###human: Show the leader names and locations of colleges. ###assistant: SELECT Leader_Name, College_Location FROM college
###context:CREATE TABLE member (Name VARCHAR, College_ID VARCHAR); CREATE TABLE college (Name VARCHAR, College_ID VARCHAR) ###human: Show the names of members and names of colleges they go to. ###assistant: SELECT T2.Name, T1.Name FROM college AS T1 JOIN member AS T2 ON T1.College_ID = T2.College_ID
###context:CREATE TABLE member (Name VARCHAR, College_ID VARCHAR); CREATE TABLE college (College_Location VARCHAR, College_ID VARCHAR) ###human: Show the names of members and the locations of colleges they go to in ascending alphabetical order of member names. ###assistant: 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
###context:CREATE TABLE college (Leader_Name VARCHAR, College_ID VARCHAR); CREATE TABLE member (College_ID VARCHAR, Country VARCHAR) ###human: Show the distinct leader names of colleges associated with members from country "Canada". ###assistant: SELECT DISTINCT T1.Leader_Name FROM college AS T1 JOIN member AS T2 ON T1.College_ID = T2.College_ID WHERE T2.Country = "Canada"
###context:CREATE TABLE member (Name VARCHAR, Member_ID VARCHAR); CREATE TABLE round (Decoration_Theme VARCHAR, Member_ID VARCHAR) ###human: Show the names of members and the decoration themes they have. ###assistant: SELECT T1.Name, T2.Decoration_Theme FROM member AS T1 JOIN round AS T2 ON T1.Member_ID = T2.Member_ID
###context:CREATE TABLE round (Member_ID VARCHAR, Rank_in_Round INTEGER); CREATE TABLE member (Name VARCHAR, Member_ID VARCHAR) ###human: Show the names of members that have a rank in round higher than 3. ###assistant: SELECT T1.Name FROM member AS T1 JOIN round AS T2 ON T1.Member_ID = T2.Member_ID WHERE T2.Rank_in_Round > 3
###context:CREATE TABLE member (Name VARCHAR, Member_ID VARCHAR); CREATE TABLE round (Member_ID VARCHAR) ###human: Show the names of members in ascending order of their rank in rounds. ###assistant: SELECT T1.Name FROM member AS T1 JOIN round AS T2 ON T1.Member_ID = T2.Member_ID ORDER BY Rank_in_Round
###context:CREATE TABLE member (Name VARCHAR, Member_ID VARCHAR); CREATE TABLE round (Name VARCHAR, Member_ID VARCHAR) ###human: List the names of members who did not participate in any round. ###assistant: SELECT Name FROM member WHERE NOT Member_ID IN (SELECT Member_ID FROM round)
###context:CREATE TABLE documents (document_name VARCHAR, access_count VARCHAR) ###human: Find the name and access counts of all documents, in alphabetic order of the document name. ###assistant: SELECT document_name, access_count FROM documents ORDER BY document_name
###context:CREATE TABLE documents (document_name VARCHAR, access_count VARCHAR) ###human: 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? ###assistant: SELECT document_name, access_count FROM documents ORDER BY access_count DESC LIMIT 1
###context:CREATE TABLE documents (document_type_code VARCHAR) ###human: Find the types of documents with more than 4 documents. ###assistant: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING COUNT(*) > 4
###context:CREATE TABLE documents (access_count INTEGER, document_type_code VARCHAR) ###human: Find the total access count of all documents in the most popular document type. ###assistant: SELECT SUM(access_count) FROM documents GROUP BY document_type_code ORDER BY COUNT(*) DESC LIMIT 1
###context:CREATE TABLE documents (access_count INTEGER) ###human: What is the average access count of documents? ###assistant: SELECT AVG(access_count) FROM documents
###context:CREATE TABLE document_structures (document_structure_description VARCHAR, document_structure_code VARCHAR); CREATE TABLE documents (document_structure_code VARCHAR) ###human: What is the structure of the document with the least number of accesses? ###assistant: 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
###context:CREATE TABLE documents (document_type_code VARCHAR, document_name VARCHAR) ###human: What is the type of the document named "David CV"? ###assistant: SELECT document_type_code FROM documents WHERE document_name = "David CV"
###context:CREATE TABLE documents (document_name VARCHAR, document_type_code VARCHAR, document_structure_code VARCHAR) ###human: Find the list of documents that are both in the most three popular type and have the most three popular structure. ###assistant: 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
###context:CREATE TABLE documents (document_type_code VARCHAR, access_count INTEGER) ###human: What document types do have more than 10000 total access number. ###assistant: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING SUM(access_count) > 10000
###context:CREATE TABLE documents (document_code VARCHAR, document_name VARCHAR); CREATE TABLE document_sections (section_title VARCHAR, document_code VARCHAR) ###human: What are all the section titles of the document named "David CV"? ###assistant: 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"