Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Which clubs are located at "AKW"? Return the club names. [/INST]

Output: SELECT clubname FROM club WHERE clublocation  =  "AKW";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: How many clubs are located at "HHH"? [/INST]

Output: SELECT count(*) FROM club WHERE clublocation  =  "HHH";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

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

Output: SELECT count(*) FROM club WHERE clublocation  =  "HHH";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: What are the first and last name of the president of the club "Bootup Baltimore"? [/INST]

Output: SELECT t3.fname ,  t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Bootup Baltimore" AND t2.position  =  "President";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Who is the president of the club "Bootup Baltimore"? Give me the first and last name. [/INST]

Output: SELECT t3.fname ,  t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Bootup Baltimore" AND t2.position  =  "President";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Who is the "CTO" of club "Hopkins Student Enterprises"? Show the first name and last name. [/INST]

Output: SELECT t3.fname ,  t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Hopkins Student Enterprises" AND t2.position  =  "CTO";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Find the first name and last name for the "CTO" of the club "Hopkins Student Enterprises"? [/INST]

Output: SELECT t3.fname ,  t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Hopkins Student Enterprises" AND t2.position  =  "CTO";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: How many different roles are there in the club "Bootup Baltimore"? [/INST]

Output: SELECT count(DISTINCT t2.position) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid WHERE t1.clubname  =  "Bootup Baltimore";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of different positions in the club "Bootup Baltimore". [/INST]

Output: SELECT count(DISTINCT t2.position) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid WHERE t1.clubname  =  "Bootup Baltimore";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: How many members of "Bootup Baltimore" are older than 18? [/INST]

Output: SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Bootup Baltimore" AND t3.age  >  18;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of members in club "Bootup Baltimore" whose age is above 18. [/INST]

Output: SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Bootup Baltimore" AND t3.age  >  18;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: How many members of club "Bootup Baltimore" are younger than 18? [/INST]

Output: SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Bootup Baltimore" AND t3.age  <  18;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of members in club "Bootup Baltimore" whose age is below 18. [/INST]

Output: SELECT count(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Bootup Baltimore" AND t3.age  <  18;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Find the names of all the clubs that have at least a member from the city with city code "BAL". [/INST]

Output: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.city_code  =  "BAL";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Which clubs have one or more members from the city with code "BAL"? Give me the names of the clubs. [/INST]

Output: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.city_code  =  "BAL";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Find the names of the clubs that have at least a member from the city with city code "HOU". [/INST]

Output: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.city_code  =  "HOU";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Which clubs have one or more members from the city with code "HOU"? Give me the names of the clubs. [/INST]

Output: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.city_code  =  "HOU";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: How many clubs does the student named "Eric Tai" belong to? [/INST]

Output: SELECT count(DISTINCT t1.clubname) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.fname  =  "Eric" AND t3.lname  =  "Tai";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Count the number of clubs for which the student named "Eric Tai" is a member. [/INST]

Output: SELECT count(DISTINCT t1.clubname) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.fname  =  "Eric" AND t3.lname  =  "Tai";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: List the clubs having "Davis Steven" as a member. [/INST]

Output: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.fname  =  "Davis" AND t3.lname  =  "Steven";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of the clubs that have "Davis Steven" as a member? [/INST]

Output: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.fname  =  "Davis" AND t3.lname  =  "Steven";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: List the clubs that have at least a member with advisor "1121". [/INST]

Output: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.advisor  =  1121;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Which clubs have one or more members whose advisor is "1121"? [/INST]

Output: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t3.advisor  =  1121;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: What is the average age of the members of the club "Bootup Baltimore"? [/INST]

Output: SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Bootup Baltimore";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Find the average age of the members in the club "Bootup Baltimore". [/INST]

Output: SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Bootup Baltimore";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Find the average age of members of the club "Hopkins Student Enterprises". [/INST]

Output: SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Hopkins Student Enterprises";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: On average, how old are the members in the club "Hopkins Student Enterprises"? [/INST]

Output: SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Hopkins Student Enterprises";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Retrieve the average age of members of the club "Tennis Club". [/INST]

Output: SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Tennis Club";


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Club :
ClubID [ INT ] primary_key
ClubName [ TEXT ]
ClubDesc [ TEXT ]
ClubLocation [ TEXT ]

Member_of_club :
StuID [ INT ] Member_of_club.StuID = Student.StuID
ClubID [ INT ] Member_of_club.ClubID = Club.ClubID
Position [ TEXT ]

Please write me a SQL statement that answers the following question: Compute the average age of the members in the club "Tennis Club". [/INST]

Output: SELECT avg(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid  =  t2.clubid JOIN student AS t3 ON t2.stuid  =  t3.stuid WHERE t1.clubname  =  "Tennis Club";


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct grant amount for the grants where the documents were sent before '1986-08-26 20:49:27' and grant were ended after '1989-03-16 18:27:16'? [/INST]

Output: SELECT T1.grant_amount FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id  =  T2.grant_id WHERE T2.sent_date  <  '1986-08-26 20:49:27' INTERSECT SELECT grant_amount FROM grants WHERE grant_end_date  >  '1989-03-16 18:27:16';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the different grant amounts for documents sent before '1986-08-26 20:49:27' and after the grant ended on '1989-03-16 18:27:16'? [/INST]

Output: SELECT T1.grant_amount FROM Grants AS T1 JOIN Documents AS T2 ON T1.grant_id  =  T2.grant_id WHERE T2.sent_date  <  '1986-08-26 20:49:27' INTERSECT SELECT grant_amount FROM grants WHERE grant_end_date  >  '1989-03-16 18:27:16';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: List the project details of the project both producing patent and paper as outcomes. [/INST]

Output: SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id  =  T2.project_id WHERE T2.outcome_code  =  'Paper' INTERSECT SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id  =  T2.project_id WHERE T2.outcome_code  =  'Patent';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the details of the project that is producing both patents and papers as outcomes? [/INST]

Output: SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id  =  T2.project_id WHERE T2.outcome_code  =  'Paper' INTERSECT SELECT T1.project_details FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id  =  T2.project_id WHERE T2.outcome_code  =  'Patent';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the total grant amount of the organisations described as research? [/INST]

Output: SELECT sum(grant_amount) FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id  =  T2.organisation_id JOIN organisation_Types AS T3 ON T2.organisation_type  =  T3.organisation_type WHERE T3.organisation_type_description  =  'Research';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the total amount of grant money for research? [/INST]

Output: SELECT sum(grant_amount) FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id  =  T2.organisation_id JOIN organisation_Types AS T3 ON T2.organisation_type  =  T3.organisation_type WHERE T3.organisation_type_description  =  'Research';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: List from which date and to which date these staff work: project staff of the project which hires the most staffs [/INST]

Output: SELECT date_from ,  date_to FROM Project_Staff WHERE project_id IN( SELECT project_id FROM Project_Staff GROUP BY project_id ORDER BY count(*) DESC LIMIT 1 ) UNION SELECT date_from ,  date_to FROM Project_Staff WHERE role_code  =  'leader';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: From what date and to what date do the staff work on a project that has the most staff and has staff in a leader role? [/INST]

Output: SELECT date_from ,  date_to FROM Project_Staff WHERE project_id IN( SELECT project_id FROM Project_Staff GROUP BY project_id ORDER BY count(*) DESC LIMIT 1 ) UNION SELECT date_from ,  date_to FROM Project_Staff WHERE role_code  =  'leader';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Find the organisation ids and details of the organisations which are involved in [/INST]

Output: SELECT T2.organisation_id ,  T2.organisation_details FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id  =  T2.organisation_id GROUP BY T2.organisation_id HAVING sum(T1.grant_amount)  >  6000;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids and details for all organizations that have grants of more than 6000 dollars? [/INST]

Output: SELECT T2.organisation_id ,  T2.organisation_details FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id  =  T2.organisation_id GROUP BY T2.organisation_id HAVING sum(T1.grant_amount)  >  6000;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the organisation type and id of the organisation which has the most number of research staff? [/INST]

Output: SELECT T1.organisation_type ,  T1.organisation_id 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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the type and id of the organization that has the most research staff? [/INST]

Output: SELECT T1.organisation_type ,  T1.organisation_id 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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Which organisation type hires most research staff? [/INST]

Output: SELECT T1.organisation_type FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id  =  T2.employer_organisation_id GROUP BY T1.organisation_type ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the type of the organization with the most research staff? [/INST]

Output: SELECT T1.organisation_type FROM Organisations AS T1 JOIN Research_Staff AS T2 ON T1.organisation_id  =  T2.employer_organisation_id GROUP BY T1.organisation_type ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: Find out the send dates of the documents with the grant amount of more than 5000 were granted by organisation type described [/INST]

Output: 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';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the send dates for all documents that have a grant amount of more than 5000 and are involved in research? [/INST]

Output: 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';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the response received dates for the documents described as 'Regular' or granted with more than 100? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the response received date for the document described as Regular that was granted more than 100 dollars? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: List the project details of the projects which did not hire any staff for a researcher role. [/INST]

Output: SELECT project_details FROM Projects WHERE project_id NOT IN ( SELECT project_id FROM Project_Staff WHERE role_code  =  'researcher' );


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the details for all projects that did not hire any staff in a research role? [/INST]

Output: SELECT project_details FROM Projects WHERE project_id NOT IN ( SELECT project_id FROM Project_Staff WHERE role_code  =  'researcher' );


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the task details, task id and project id for the projects which are detailed as 'omnis' or  have more than 2 outcomes? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the task details, task ids, and project ids for the progrects that are detailed as 'omnis' or have at least 3 outcomes? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: When do all the researcher role staff start to work, and when do they stop working? [/INST]

Output: SELECT date_from ,  date_to FROM Project_Staff WHERE role_code  =  'researcher';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: When did researchers start and stop working? [/INST]

Output: SELECT date_from ,  date_to FROM Project_Staff WHERE role_code  =  'researcher';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many kinds of roles are there for the staff? [/INST]

Output: SELECT count(DISTINCT role_code) FROM Project_Staff;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many different roles are there on the project staff? [/INST]

Output: SELECT count(DISTINCT role_code) FROM Project_Staff;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the total amount of grants given by each organisations? Also list the organisation id. [/INST]

Output: SELECT sum(grant_amount) ,  organisation_id FROM Grants GROUP BY organisation_id;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the total amount of grant money given to each organization and what is its id? [/INST]

Output: SELECT sum(grant_amount) ,  organisation_id FROM Grants GROUP BY organisation_id;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: List the project details of the projects with the research outcome described with the substring 'Published'. [/INST]

Output: 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%';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What are the details for the project whose research has been published? [/INST]

Output: 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%';


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: How many staff does each project has? List the project id and the number in an ascending order. [/INST]

Output: 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(*) ASC;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: For each project id, how many staff does it have? List them in increasing order. [/INST]

Output: 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(*) ASC;


Input:
[INST] Here is a database schema:
Document_Types :
document_type_code [ TEXT ] primary_key
document_description [ TEXT ]

Documents :
document_id [ INT ] primary_key
document_type_code [ TEXT ] Documents.document_type_code = Document_Types.document_type_code
grant_id [ INT ] Documents.grant_id = Grants.grant_id
sent_date [ TEXT ]
response_received_date [ TEXT ]
other_details [ TEXT ]

Grants :
grant_id [ INT ] primary_key
organisation_id [ INT ] Grants.organisation_id = Organisations.organisation_id
grant_amount [ INT ]
grant_start_date [ TEXT ]
grant_end_date [ TEXT ]
other_details [ TEXT ]

Organisation_Types :
organisation_type [ TEXT ] primary_key
organisation_type_description [ TEXT ]

Organisations :
organisation_id [ INT ] primary_key
organisation_type [ TEXT ] Organisations.organisation_type = Organisation_Types.organisation_type
organisation_details [ TEXT ]

Project_Outcomes :
project_id [ INT ] Project_Outcomes.project_id = Projects.project_id
outcome_code [ TEXT ] Project_Outcomes.outcome_code = Research_Outcomes.outcome_code
outcome_details [ TEXT ]

Project_Staff :
staff_id [ INT ] primary_key
project_id [ INT ] Project_Staff.project_id = Projects.project_id
role_code [ TEXT ] Project_Staff.role_code = Staff_Roles.role_code
date_from [ TEXT ]
date_to [ TEXT ]
other_details [ TEXT ]

Projects :
project_id [ INT ] primary_key
organisation_id [ INT ] Projects.organisation_id = Organisations.organisation_id
project_details [ TEXT ]

Research_Outcomes :
outcome_code [ TEXT ] primary_key
outcome_description [ TEXT ]

Research_Staff :
staff_id [ INT ] primary_key
employer_organisation_id [ INT ] Research_Staff.employer_organisation_id = Organisations.organisation_id
staff_details [ TEXT ]

Staff_Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Tasks :
task_id [ INT ] primary_key
project_id [ INT ] Tasks.project_id = Projects.project_id
task_details [ TEXT ]
eg Agree Objectives [ TEXT ]

Please write me a SQL statement that answers the following question: What is the complete description of the researcher role. [/INST]

Output: SELECT role_description FROM Staff_Roles WHERE role_code  =  'researcher';